dispatchAndWaitAll method
Future<List<ReduxAction<St> > >
dispatchAndWaitAll(
- List<
ReduxAction< actions, {St> > - bool notify = true,
inherited
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.
var actions = await store.dispatchAndWaitAll([BuyAction('IBM'), SellAction('TSLA')]);
Note this is exactly the same as doing:
var action1 = BuyAction('IBM');
var action2 = SellAction('TSLA');
dispatch(action1);
dispatch(action2);
await store.waitAllActions([action1, action2], completeImmediately = true);
var actions = [action1, action2];
If you pass the notify
parameter as false
, widgets will not necessarily rebuild because
of these actions, even if they change the state.
Note: While the state change from the action's reducers will have been applied when the Future resolves, other independent processes that the action may have started may still be in progress.
See also:
dispatch
which dispatches both sync and async actions.dispatchAndWait
which dispatches both sync and async actions, and returns a Future.dispatchSync
which dispatches sync actions, and throws if the action is async.dispatchAll
which dispatches all given actions in parallel.
Implementation
Future<List<ReduxAction<St>>> dispatchAndWaitAll(
List<ReduxAction<St>> actions, {
bool notify = true,
}) async {
var futures = <Future<ActionStatus>>[];
for (var action in actions) {
futures.add(dispatchAndWait(action, notify: notify));
}
await Future.wait(futures);
return actions;
}