asyncredux-dispatching-actions
Comprehensive dispatching utilities for AsyncRedux in Flutter applications.
Install
mkdir -p .claude/skills/asyncredux-dispatching-actions && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5099" && unzip -o skill.zip -d .claude/skills/asyncredux-dispatching-actions && rm skill.zipInstalls to .claude/skills/asyncredux-dispatching-actions
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Dispatch actions using all available methods: `dispatch()`, `dispatchAndWait()`, `dispatchAll()`, `dispatchAndWaitAll()`, and `dispatchSync()`. Covers dispatching from widgets via context extensions and from within other actions.Key capabilities
- →Dispatches actions synchronously or asynchronously via context
- →Waits for state changes to trigger post-action navigation or logic
- →Batches parallel actions to update state efficiently
- →Enforces synchronous execution for critical tasks
- →Exposes dispatch methods as context extensions for widgets
How it works
Wraps state updates in Redux action classes and uses the Store instance to manage global state flow and notification cycles.
Inputs & outputs
When to use asyncredux-dispatching-actions
- →Dispatching actions from UI widgets
- →Waiting for state changes after dispatch
- →Batching multiple actions in parallel
About this skill
Dispatching Actions
The foundational principle of AsyncRedux: the only way to change the application state is by dispatching actions. You can dispatch from widgets (via context extensions) or from within other actions.
Five Dispatch Methods
1. dispatch()
The standard method that returns immediately. For synchronous actions, state updates before return; for async actions, the process begins and completes later.
dispatch(MyAction());
2. dispatchAndWait()
Returns a Future that completes when the action finishes and state changes, regardless of whether the action is sync or async. Returns an ActionStatus object.
var status = await dispatchAndWait(MyAction());
if (status.isCompletedOk) {
Navigator.pop(context);
}
3. dispatchAll()
Dispatches multiple actions in parallel, returning the list of dispatched actions.
dispatchAll([BuyAction('IBM'), SellAction('TSLA')]);
4. dispatchAndWaitAll()
Dispatches actions in parallel and waits for all to complete.
await dispatchAndWaitAll([
BuyAction('IBM'),
SellAction('TSLA'),
]);
5. dispatchSync()
Like dispatch() but throws a StoreException if the action is asynchronous. Use when synchronous execution is mandatory.
dispatchSync(MyAction());
Dispatching from Widgets
All dispatch methods are available as BuildContext extensions:
context.dispatch(Action());
context.dispatchAll([Action1(), Action2()]);
await context.dispatchAndWait(Action());
await context.dispatchAndWaitAll([Action1(), Action2()]);
context.dispatchSync(Action());
Example button implementation:
ElevatedButton(
onPressed: () => context.dispatch(Increment()),
child: Text('Increment'),
)
For async dispatch in callbacks:
ElevatedButton(
onPressed: () async {
var status = await context.dispatchAndWait(SaveAction());
if (status.isCompletedOk) {
Navigator.pop(context);
}
},
child: Text('Save'),
)
Dispatching from Within Actions
All dispatch methods are available inside actions via the ReduxAction base class:
class MyAction extends ReduxAction<AppState> {
Future<AppState?> reduce() async {
// Dispatch another action and wait for it
await dispatchAndWait(LoadDataAction());
// Dispatch without waiting
dispatch(LogAction('Data loaded'));
return state.copy(loaded: true);
}
}
Dispatching in before() and after()
You can dispatch actions in the before() and after() lifecycle methods:
class MyAction extends ReduxAction<AppState> {
Future<AppState?> reduce() async {
String description = await fetchData();
return state.copy(description: description);
}
void before() => dispatch(BarrierAction(true));
void after() => dispatch(BarrierAction(false));
}
ActionStatus
The dispatchAndWait() method returns an ActionStatus object with useful properties:
var status = await dispatchAndWait(MyAction());
// Check completion state
status.isCompleted; // Action finished executing
status.isCompletedOk; // Completed without errors
status.isCompletedFailed; // Completed with errors
// Access error information
status.originalError; // Error thrown by before/reduce
status.wrappedError; // Error after wrapError() processing
// Check method completion
status.hasFinishedMethodBefore;
status.hasFinishedMethodReduce;
status.hasFinishedMethodAfter;
You can also access status directly from the action instance:
var action = MyAction();
await dispatchAndWait(action);
print(action.status.isCompletedOk);
The notify Parameter
Dispatch methods accept an optional notify parameter (default true) that controls whether widgets rebuild on state changes:
// Dispatch without triggering widget rebuilds
dispatch(MyAction(), notify: false);
Summary Table
| Method | Returns | Waits? | Use Case |
|---|---|---|---|
dispatch() | void | No | Fire and forget |
dispatchAndWait() | Future<ActionStatus> | Yes | Need to know when done |
dispatchAll() | List<ReduxAction> | No | Multiple parallel actions |
dispatchAndWaitAll() | Future<void> | Yes | Wait for all parallel actions |
dispatchSync() | void | N/A | Enforce sync execution |
References
URLs from the documentation:
- https://asyncredux.com/flutter/basics/dispatching-actions
- https://asyncredux.com/flutter/basics/using-the-store-state
- https://asyncredux.com/flutter/basics/sync-actions
- https://asyncredux.com/flutter/basics/async-actions
- https://asyncredux.com/flutter/basics/store
- https://asyncredux.com/flutter/advanced-actions/redux-action
- https://asyncredux.com/flutter/advanced-actions/action-status
- https://asyncredux.com/flutter/advanced-actions/before-and-after-the-reducer
- https://asyncredux.com/flutter/testing/dispatch-wait-and-expect
- https://asyncredux.com/flutter/miscellaneous/advanced-waiting
When not to use it
- →When simple setState is sufficient for local widget state
- →When action logic doesn't require centralized state updates
Prerequisites
Limitations
- →Adds boilerplate for simple state updates
- →Overuse of sync dispatches can block UI frames
How it compares
It formalizes state management by routing all state changes through defined, testable actions rather than arbitrary code.
Compared to similar skills
asyncredux-dispatching-actions side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| asyncredux-dispatching-actions (this skill) | 1 | 6mo | No flags | Intermediate |
| new-feature-scaffold | 0 | 3mo | Review | Beginner |
| flutter-development | 1,555 | 5mo | No flags | Intermediate |
| flutter-expert | 73 | 4mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by marcglasberg
View all by marcglasberg →You might also like
new-feature-scaffold
TarekAlabd
Step-by-step checklist and templates for adding a new feature to this Flutter social media app — directory structure, model, service, cubit, view, and routing wiring.
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
flutter-expert
sickn33
Master Flutter development with Dart 3, advanced widgets, and multi-platform deployment. Handles state management, animations, testing, and performance optimization for mobile, web, desktop, and embedded platforms. Use PROACTIVELY for Flutter architecture, UI implementation, or cross-platform features.
flutter
alinaqi
Flutter development with Riverpod state management, Freezed, go_router, and mocktail testing
flutter-architecture-expert
flutter-it
Architecture guidance for Flutter apps using the flutter_it construction set (get_it, watch_it, command_it, listen_it). Covers Pragmatic Flutter Architecture (PFA) with Services/Managers/Views, feature-based project structure, manager pattern, proxy pattern with optimistic updates and override fields, DataRepository with reference counting, scoped services, widget granularity, testing, and best practices. Use when designing app architecture, structuring Flutter projects, implementing managers or proxies, or planning feature organization.
mobile-developer
sickn33
Develop React Native, Flutter, or native mobile apps with modern architecture patterns. Masters cross-platform development, native integrations, offline sync, and app store optimization. Use PROACTIVELY for mobile features, cross-platform code, or app optimization.