Store class

A Store is a repository and manager of app state. This class should be extended to fit the needs of your application and its data. The number and hierarchy of stores is dependent upon the state management needs of your application.

General guidelines with respect to a Store's data:

  • A Store's data should not be exposed for direct mutation.
  • A Store's data should be mutated internally in response to Actions.
  • A Store should expose relevant data ONLY via public getters.

To receive notifications of a Store's data mutations, Stores can be listened to. Whenever a Store's data is mutated, the trigger method is used to tell all registered listeners that updated data is available.

In a typical application using w_flux, a FluxComponent listens to Stores, triggering re-rendering of the UI elements based on the updated Store data.

Mixed in types

Constructors

Store()
Construct a new Store instance.
Store.withTransformer(StreamTransformer transformer)
Construct a new Store instance with a transformer. [...]

Properties

disposableTypeName → String
A type name, similar to runtimeType but intended to work with minified code. [...]
read-only, override
isBroadcast → bool
Whether this stream is a broadcast stream.
read-only
stream → Stream<Store>
The stream underlying trigger events and listen. [...]
@Deprecated('3.0.0'), @visibleForTesting, read-only
didDispose → Future<Null>
A Future that will complete when this object has been disposed.
read-only, inherited
disposalTreeSize → int
The total size of the disposal tree rooted at the current Disposable instance. [...]
read-only, inherited
first → Future<Store>
The first element of this stream.
read-only, inherited
hashCode → int
The hash code for this object.
read-only, inherited
isDisposed → bool
Whether this object has been disposed.
read-only, inherited
isDisposedOrDisposing → bool
Whether this object has been disposed or is currently disposing. [...]
read-only, inherited
isDisposing → bool
Whether this object is in the process of being disposed. [...]
read-only, inherited
isEmpty → Future<bool>
Whether this stream contains any elements.
read-only, inherited
isLeakFlagSet → bool
Whether the leak flag for this object has been set. [...]
read-only, inherited
isOrWillBeDisposed → bool
Whether the disposal of this object has been requested, is in progress, or is complete. [...]
read-only, inherited
last → Future<Store>
The last element of this stream.
read-only, inherited
length → Future<int>
The number of elements in this stream.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
single → Future<Store>
The single element of this stream.
read-only, inherited

Methods

listen(StoreHandler onData, { Function onError, void onDone(), bool cancelOnError }) → StreamSubscription<Store>
Adds a subscription to this Store. [...]
manageActionSubscription(ActionSubscription subscription) → void
Registers an ActionSubscription to be canceled when the store is disposed. [...]
@mustCallSuper, @protected
trigger() → void
Trigger a "data updated" event. All registered listeners of this Store will receive the event, at which point they can use the latest data from this Store as necessary. [...]
triggerOnAction(Action action, [ void onAction(dynamic payload) ]) → dynamic
A convenience method for listening to an action and triggering automatically once the callback for said action has completed. [...]
triggerOnActionV2<T>(Action<T> action, [ FutureOr onAction(T payload) ]) → void
A convenience method for listening to an action and triggering automatically once the callback for said action has completed. [...]
any(bool test(Store element)) → Future<bool>
Checks whether test accepts any element provided by this stream.
inherited
asBroadcastStream({void onListen(StreamSubscription<Store> subscription) void onCancel(StreamSubscription<Store> subscription) }) → Stream<Store>
Returns a multi-subscription stream that produces the same events as this.
inherited
asyncExpand<E>(Stream<E> convert(Store event)) → Stream<E>
Transforms each element into a sequence of asynchronous events.
inherited
asyncMap<E>(FutureOr<E> convert(Store event)) → Stream<E>
Creates a new stream with each data event of this stream asynchronously mapped to a new event.
inherited
awaitBeforeDispose<T>(Future<T> future) → Future<T>
Add future to a list of futures that will be awaited before the object is disposed. [...]
@mustCallSuper, inherited
cast<R>() → Stream<R>
Adapt this stream to be a Stream<R>.
inherited
contains(Object needle) → Future<bool>
Returns whether needle occurs in the elements provided by this stream.
inherited
dispose() → Future<Null>
Dispose of the object, cleaning up to prevent memory leaks.
inherited
distinct([bool equals(Store previous Store next) ]) → Stream<Store>
Skips data events if they are equal to the previous data event.
inherited
drain<E>([E futureValue ]) → Future<E>
Discards all data on this stream, but signals when it is done or an error occurred.
inherited
elementAt(int index) → Future<Store>
Returns the value of the indexth data event of this stream.
inherited
every(bool test(Store element)) → Future<bool>
Checks whether test accepts all elements provided by this stream.
inherited
expand<S>(Iterable<S> convert(Store element)) → Stream<S>
Transforms each element of this stream into a sequence of elements.
inherited
firstWhere(bool test(Store element), { Store orElse() }) → Future<Store>
Finds the first element of this stream matching test.
inherited
flagLeak([String description ]) → void
Flag the object as having been disposed in a way that allows easier profiling. [...]
@mustCallSuper, inherited
fold<S>(S initialValue, S combine(S previous, Store element)) → Future<S>
Combines a sequence of values by repeatedly applying combine.
inherited
forEach(void action(Store element)) → Future
Executes action on each element of this stream.
inherited
getManagedDelayedFuture<T>(Duration duration, T callback()) → Future<T>
Creates a Future that will complete, with the value returned by callback, after the given amount of time has elapsed. [...]
@mustCallSuper, inherited
getManagedDisposer(Disposer disposer) ManagedDisposer
Automatically handle arbitrary disposals using a callback. [...]
@mustCallSuper, inherited
getManagedPeriodicTimer(Duration duration, void callback(Timer timer)) → Timer
Creates a periodic Timer that will be cancelled if active upon disposal.
@mustCallSuper, inherited
getManagedTimer(Duration duration, void callback()) → Timer
Creates a Timer instance that will be cancelled if active upon disposal.
@mustCallSuper, inherited
handleError(Function onError, { bool test(dynamic error) }) → Stream<Store>
Creates a wrapper Stream that intercepts some errors from this stream.
inherited
join([String separator = "" ]) → Future<String>
Combines the string representation of elements into a single string.
inherited
lastWhere(bool test(Store element), { Store orElse() }) → Future<Store>
Finds the last element in this stream matching test.
inherited
listenToStream<T>(Stream<T> stream, void onData(T event), { Function onError, void onDone(), bool cancelOnError }) → StreamSubscription<T>
Returns a StreamSubscription which handles events from the stream using the provided onData, onError and onDone handlers. [...]
@mustCallSuper, inherited
manageAndReturnDisposable(Disposable disposable) Disposable
Automatically dispose another object when this object is disposed. [...]
@mustCallSuper, inherited
manageAndReturnTypedDisposable<T extends Disposable>(T disposable) → T
Automatically dispose another object when this object is disposed. [...]
@mustCallSuper, inherited
manageCompleter<T>(Completer<T> completer) → Completer<T>
Ensure that a completer is completed when the object is disposed. [...]
@mustCallSuper, inherited
manageDisposable(Disposable disposable) → void
Automatically dispose another object when this object is disposed. [...]
@mustCallSuper, inherited
manageDisposer(Disposer disposer) → void
Automatically handle arbitrary disposals using a callback. [...]
@mustCallSuper, inherited
manageStreamController(StreamController controller) → void
Automatically cancel a stream controller when this object is disposed. [...]
@mustCallSuper, inherited
manageStreamSubscription(StreamSubscription subscription) → void
Automatically cancel a stream subscription when this object is disposed. [...]
@mustCallSuper, inherited
map<S>(S convert(Store event)) → Stream<S>
Transforms each element of this stream into a new stream event.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
onDispose() → Future<Null>
Callback to allow arbitrary cleanup on dispose.
@protected, inherited
onWillDispose() → Future<Null>
Callback to allow arbitrary cleanup as soon as disposal is requested (i.e. dispose is called) but prior to disposal actually starting. [...]
@protected, inherited
pipe(StreamConsumer<Store> streamConsumer) → Future
Pipes the events of this stream into streamConsumer.
inherited
reduce(Store combine(Store previous Store element)) → Future<Store>
Combines a sequence of values by repeatedly applying combine.
inherited
singleWhere(bool test(Store element), { Store orElse() }) → Future<Store>
Finds the single element in this stream matching test.
inherited
skip(int count) → Stream<Store>
Skips the first count data events from this stream.
inherited
skipWhile(bool test(Store element)) → Stream<Store>
Skip data events from this stream while they are matched by test.
inherited
take(int count) → Stream<Store>
Provides at most the first count data events of this stream.
inherited
takeWhile(bool test(Store element)) → Stream<Store>
Forwards data events while test is successful.
inherited
timeout(Duration timeLimit, { void onTimeout(EventSink<Store> sink) }) → Stream<Store>
Creates a new stream with the same events as this stream.
inherited
toList() → Future<List<Store>>
Collects all elements of this stream in a List.
inherited
toSet() → Future<Set<Store>>
Collects the data of this stream in a Set.
inherited
toString() → String
Returns a string representation of this object.
inherited
transform<S>(StreamTransformer<Store, S> streamTransformer) → Stream<S>
Applies streamTransformer to this stream.
inherited
where(bool test(Store event)) → Stream<Store>
Creates a new stream from this stream that discards some elements.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited