Store<S> class abstract

A redux like store that manages state.

Contrary to the original design the store doesn't use configured actions, but instead uses a synchronous update callback. Furthermore, various extensions are provided to asynchronously let an Observable or Future manipulate the state.

Middleware is provided by providing other implementations of the Store interface, and possibly wrapping and delegating to the DefaultStore.

The canonical example with the counter looks like this:

// Create a store with the initial value 0. final store = Store

// Subscribe to state changes and print the new state to the console. store.subscribe( => print(state)));

// Increment the value by one. In a more complicated example one // could extract the function to be standalone, or generalize it to // handle different actions. store.update((state) => state + 1);

// Alternatively, one can subscribe to an observable and provide // reducer functions for its events to update the state asynchronously. // The following lines set the state to a random value every 10 seconds. final randomValue = timer(period: Duration(seconds: 10)) .map((_) => Random().nextInt(100)); store.addObservable(randomValue, next: (state, value) => value);

Implemented types
Available Extensions


Store(S initialState)
Constructs a standard store from an initial state.


hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state → S
Returns the current state.
no setter


noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
subscribe(Observer<S> observer) Disposable
Subscribes with the provided observer.
toString() String
A string representation of this object.
update(Updater<S> updater) → S
Updates the current state.


operator ==(Object other) bool
The equality operator.