Asyncredux nonreentrant mixin

From marcglasberg/async_redux · View interactive version

Asyncredux nonreentrant mixin is an AI agent skill from the GitHub repository marcglasberg/async_redux. Use AsyncRedux NonReentrant to drop duplicate in-flight dispatches, with shared or per-entity keys.

How to use this skill

Skill file

Prevent duplicate in-flight actions

Use NonReentrant<AppState> when a duplicate should be silently aborted while an

earlier action with the same key is in progress. The default key is the action type.

Override nonReentrantKeyParams() with immutable constructor values to allow

different entities to run independently. Override computeNonReentrantKey() to

share a key across action types.

Use Sequential when every request must run in dispatch order. Pair a per-entity

non-reentrant key with statusKey when the UI also tracks status per entity. These

keys serve separate purposes, so set both when needed.

This action uses AppAction from the setup skill.

class SaveItem extends AppAction with NonReentrant<AppState> {
  SaveItem(this.itemId, this.save);
  final String itemId;
  final Future<void> Function(String) save;

  @override
  Object nonReentrantKeyParams() => itemId;

  @override
  Object get statusKey => itemId;

  @override
  Future<AppState?> reduce() async {
    await save(itemId);
    return null;
  }
}

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.