.claude/skills/asyncredux-nonreentrant-mixin/SKILL.md
Add the NonReentrant mixin to prevent an action from dispatching while already in progress. Covers preventing duplicate form submissions, avoiding race conditions, and protecting long-running operations.
npx skillsauth add marcglasberg/async_redux asyncredux-nonreentrant-mixinInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The NonReentrant mixin prevents concurrent execution of the same action type. When an action instance is already running, new dispatches of that same action are silently aborted.
Add the NonReentrant mixin to any action that should not run concurrently:
class SaveAction extends AppAction with NonReentrant {
Future<AppState?> reduce() async {
await http.put('http://myapi.com/save', body: 'data');
return null;
}
}
With this mixin:
The NonReentrant mixin overrides the abortDispatch method. When abortDispatch() returns true, the action's before(), reduce(), and after() methods will not run, and the state stays unchanged.
By default, checks are based on the action's runtime type - multiple instances of the same action class cannot run simultaneously.
Override nonReentrantKeyParams() to allow actions with different parameters to run in parallel:
class SaveItemAction extends AppAction with NonReentrant {
final String itemId;
SaveItemAction(this.itemId);
@override
Object? nonReentrantKeyParams() => itemId;
Future<AppState?> reduce() async {
await saveItem(itemId);
return null;
}
}
With this customization:
SaveItemAction('A') and SaveItemAction('B') can run concurrentlySaveItemAction('A') dispatches will still block each otherOverride computeNonReentrantKey() to make different action classes block each other:
class SaveUserAction extends AppAction with NonReentrant {
final String orderId;
SaveUserAction(this.orderId);
@override
Object? computeNonReentrantKey() => orderId;
Future<AppState?> reduce() async { ... }
}
class DeleteUserAction extends AppAction with NonReentrant {
final String orderId;
DeleteUserAction(this.orderId);
@override
Object? computeNonReentrantKey() => orderId;
Future<AppState?> reduce() async { ... }
}
This prevents SaveUserAction('123') and DeleteUserAction('123') from running simultaneously - useful when different operations on the same resource must not overlap.
You can combine NonReentrant with other compatible mixins:
class LoadDataAction extends AppAction with CheckInternet, NonReentrant {
Future<AppState?> reduce() async {
final data = await fetchData();
return state.copy(data: data);
}
}
Incompatible mixins: NonReentrant cannot be combined with:
ThrottleUnlimitedRetryCheckInternetURLs from the documentation:
data-ai
Show loading states and handle action failures in widgets. Covers `isWaiting(ActionType)` for spinners, `isFailed(ActionType)` for error states, `exceptionFor(ActionType)` for error messages, and `clearExceptionFor()` to reset failure states.
data-ai
Use `waitCondition()` inside actions to pause execution until state meets criteria. Covers waiting for price thresholds, coordinating between actions, and implementing conditional workflows.
testing
Handle user-facing errors with UserException. Covers throwing UserException from actions, setting up UserExceptionDialog, customizing error dialogs with `onShowUserExceptionDialog`, and using UserExceptionAction for non-interrupting error display.
tools
Implement undo/redo functionality using state observers. Covers recording state history with stateObserver, creating a RecoverStateAction, implementing undo for the full state or partial state, and managing history limits.