dispatchSync method
Dispatches the action, applying its reducer, and possibly changing the store state. However, if the action is ASYNC, it will throw a StoreException.
If you pass the notify
parameter as false
, widgets will not necessarily rebuild because
of this action, even if it changes the state.
Method dispatchSync is of type DispatchSync. It returns ActionStatus
,
which means you can also get the final status of the action:
var status = store.dispatchSync(MyAction());
See also:
- dispatch which dispatches both sync and async actions.
- dispatchAndWait which dispatches both sync and async actions, and returns a Future.
- dispatchAndWaitAll which dispatches all given actions, and returns a Future.
- dispatchAll which dispatches all given actions in parallel.
Implementation
ActionStatus dispatchSync(ReduxAction<St> action, {bool notify = true}) {
if (!action.isSync()) {
throw StoreException(
"Can't dispatchSync(${action.runtimeType}) because ${action.runtimeType} is async.");
}
return _dispatch(action, notify: notify) as ActionStatus;
}