isCompletedOk property
bool
isCompletedOk
Returns true only if the action has completed, and none of the 'before' or 'reduce' methods have thrown an error. This indicates that the 'reduce' method completed and returned a result (even if the result was null). The 'after' method also already ran.
This can be useful if you need to dispatch a second method only if the first method succeeded:
let action = new LoadInfo();
await dispatchAndWait(action);
if (action.isCompletedOk) dispatch(new ShowInfo());
Or you can also get the state directly from dispatchAndWait
:
var status = await dispatchAndWait(LoadInfo());
if (status.isCompletedOk) dispatch(ShowInfo());
Implementation
bool get isCompletedOk => isCompleted && (originalError == null);