clearExceptionFor method
Removes the given actionTypeOrList
from the list of action types that failed.
Note that dispatching an action already removes that action type from the exceptions list. This removal happens as soon as the action is dispatched, not when it finishes.
actionTypeOrList
can be a Type, or an Iterable of types. Any other type
of object will return null and throw a StoreException after the async gap.
Note: This method uses the EXACT type in actionTypeOrList
. Subtypes are not considered.
Implementation
void clearExceptionFor(Object actionTypeOrList) {
//
// 1) If a type was passed:
if (actionTypeOrList is Type) {
var result = _failedActions.remove(actionTypeOrList);
if (result != null) _changeController.add(state);
}
//
// 2) If a list was passed:
else if (actionTypeOrList is Iterable) {
Object? result;
for (var actionType in actionTypeOrList) {
if (actionType is Type) {
result = _failedActions.remove(actionType);
} else {
Future.microtask(() {
throw StoreException("You can't clearExceptionFor([${actionTypeOrList.runtimeType}]), "
"but only an action Type, or a List of types.");
});
}
}
if (result != null) _changeController.add(state);
}
// 3) If something different was passed, it's an error. We show the error after the
// async gap, so we don't interrupt the code. But we return null.
else {
Future.microtask(() {
throw StoreException("You can't clearExceptionFor(${actionTypeOrList.runtimeType}), "
"but only an action Type, or a List of types.");
});
}
}