.claude/skills/asyncredux-check-internet-mixin/SKILL.md
Add the CheckInternet mixin to ensure network connectivity before action execution. Covers automatic error dialogs, combining with NoDialog for custom UI handling, and AbortWhenNoInternet for silent abort.
npx skillsauth add marcglasberg/async_redux asyncredux-check-internet-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 CheckInternet mixin verifies device connectivity before an action executes. If there's no internet connection, the action aborts and displays a dialog with the message: "There is no Internet. Please, verify your connection."
class LoadText extends AppAction with CheckInternet {
Future<AppState?> reduce() async {
var response = await http.get('https://api.example.com/text');
return state.copy(text: response.body);
}
}
The mixin works by overriding the before() method. If the device lacks connectivity, it throws a UserException which triggers the standard error dialog.
Override connectionException() to return a custom UserException:
class LoadText extends AppAction with CheckInternet {
@override
UserException connectionException(UserException error) {
return UserException('Unable to load data. Check your connection.');
}
Future<AppState?> reduce() async {
var response = await http.get('https://api.example.com/text');
return state.copy(text: response.body);
}
}
Use NoDialog alongside CheckInternet to suppress the automatic error dialog. This allows you to handle connectivity failures in your widgets using isFailed() and exceptionFor():
class LoadText extends AppAction with CheckInternet, NoDialog {
Future<AppState?> reduce() async {
var response = await http.get('https://api.example.com/text');
return state.copy(text: response.body);
}
}
Then handle the error in your widget:
Widget build(BuildContext context) {
if (context.isWaiting(LoadText)) {
return CircularProgressIndicator();
}
if (context.isFailed(LoadText)) {
var exception = context.exceptionFor(LoadText);
return Text('Error: ${exception?.message}');
}
return Text(context.state.text);
}
Use AbortWhenNoInternet for silent failure when offline. The action aborts without throwing errors or displaying dialogs—as if it had never been dispatched:
class RefreshData extends AppAction with AbortWhenNoInternet {
Future<AppState?> reduce() async {
var response = await http.get('https://api.example.com/data');
return state.copy(data: response.body);
}
}
This is useful for background refreshes or non-critical operations where user notification isn't needed.
This mixin combines three capabilities: internet verification, unlimited retry with exponential backoff, and non-reentrant behavior. It's ideal for essential operations like loading startup data:
class LoadAppStartupData extends AppAction with UnlimitedRetryCheckInternet {
Future<AppState?> reduce() async {
var response = await http.get('https://api.example.com/startup');
return state.copy(startupData: response.body);
}
}
Default retry parameters:
Track retry attempts via the attempts getter and customize logging through printRetries().
Important compatibility rules:
CheckInternet and AbortWhenNoInternet are incompatible with each otherCheckInternet nor AbortWhenNoInternet can be combined with UnlimitedRetryCheckInternetCheckInternet works well with Retry, NonReentrant, Throttle, Debounce, and optimistic mixinsTwo methods for simulating connectivity in tests:
Per-action simulation - Override internetOnOffSimulation within specific actions:
class LoadText extends AppAction with CheckInternet {
@override
bool? get internetOnOffSimulation => false; // Simulate offline
Future<AppState?> reduce() async {
// ...
}
}
Global simulation - Set forceInternetOnOffSimulation on the store:
var store = Store<AppState>(
initialState: AppState.initialState(),
);
store.forceInternetOnOffSimulation = false; // All actions see no internet
These mixins only detect device connectivity status. They cannot verify:
For server-specific connectivity checks, implement additional validation in your action's reduce() method or before() method.
URLs 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.