cancelAll<TAction extends Object?> function
cancel all action rule
Implementation
Rule cancelAll<TAction extends Object?>(
[bool Function(ActionBase)? predicate]) {
return (dispatcher, next) {
if (predicate != null) {
// cancel all actions that matches a predicate
for (final other in dispatcher.dispatching) {
if (predicate(other.action) == true) {
other.cancel();
}
}
} else if (null is TAction) {
// cancel all dispatching actions
for (final other in dispatcher.dispatching) {
other.cancel();
}
} else {
for (final other in dispatcher.dispatching) {
if (other.action is TAction) {
other.cancel();
}
}
}
next();
};
}