Dispatches all given actions in parallel, applying their reducer, and possibly changing
the store state. It returns the same list of actions, so that you can instantiate them
inline, but still get a list of them.
Dispatches the action, applying its reducer, and possibly changing the store state.
The action may be sync or async. In both cases, it returns a Future that resolves when
the action finishes.
Dispatches all given actions in parallel, applying their reducers, and possibly changing
the store state. The actions may be sync or async. It returns a Future that resolves when
ALL actions finish.
Gets the store environment.
This can be used to create a global value, but scoped to the store.
For example, you could have a service locator, here, or a configuration value.
Returns true only if the action finished with no errors.
In other words, if the methods before, reduce and after all finished executing
without throwing any errors.
If abortDispatch returns true, the action will NOT be dispatched: before, reduce
and after will not be called, and the action will not be visible to the store observers.
This is an optional method that may be overridden to run during action
dispatching, after reduce. If this method throws an error, the
error will be swallowed (will not throw). So you should only run code that
can't throw errors. It may be synchronous only.
Note this method will always be called,
even if errors were thrown by before or reduce.
An async reducer (one that returns Future<AppState?>) must never complete without at least
one await, because this may result in state changes being lost. It's up to you to make sure
all code paths in the reducer pass through at least one await.
This is an optional method that may be overridden to run during action
dispatching, before reduce. If this method throws an error, the
reduce method will NOT run, but the method after will.
It may be synchronous (returning void) ou async (returning Future<void>).
You should NOT return FutureOr.
Returns true if an actionOrActionTypeOrList failed with an UserException.
Note: This method uses the EXACT type in actionOrActionTypeOrList. Subtypes are not considered.
Returns true if the action is SYNC, and false if the action is ASYNC.
The action is considered SYNC if the before method, the reduce method,
and the wrapReduce methods are all synchronous.
Gets a property from the store.
This can be used to save global values, but scoped to the store.
For example, you could save timers, streams or futures used by actions.
The reduce method is the action reducer. It may read the action state,
the store state, and then return a new state (or null if no state
change is necessary).
Sets a property in the store.
This can be used to save global values, but scoped to the store.
For example, you could save timers, streams or futures used by actions.
Returns a future which will complete when the given state condition is true.
If the condition is already true when the method is called, the future completes immediately.
If any error is thrown by reduce or before, you have the chance
to further process it by using wrapError. Usually this is used to wrap
the error inside of another that better describes the failed action.
For example, if some action converts a String into a number, then instead of
throwing a FormatException you could do:
You may wrap the reducer to allow for some pre- or post-processing.
For example, if you want to prevent an async reducer to change the current state,
if the current state has already changed since when the reducer started: