asyncredux-observers
БесплатноБез исполняемых скриптовНе проверенSet up observers for debugging and monitoring. Covers implementing actionObservers for dispatch logging, stateObserver for state change tracking, combining…
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
Setting Up Observers for Debugging and Monitoring
AsyncRedux provides several observer types for monitoring actions, state changes, errors, and widget rebuilds. These observers are configured when creating the Store.
Overview of Observer Types
| Observer Type | Purpose |
|---|---|
ActionObserver |
Monitor action dispatch (start and end) |
StateObserver |
Monitor state changes after actions |
ErrorObserver |
Monitor and handle action errors |
ModelObserver |
Monitor widget rebuilds (for StoreConnector) |
Store Configuration with Observers
var store = Store<AppState>(
initialState: AppState.initialState(),
actionObservers: [ConsoleActionObserver()],
stateObservers: [MyStateObserver()],
errorObserver: MyErrorObserver(),
modelObserver: DefaultModelObserver(),
);
ActionObserver
The ActionObserver monitors when actions are dispatched and when they complete. It triggers twice per action: at the start (INI) and at the end (END).
ActionObserver Abstract Class
abstract class ActionObserver<St> {
void observe(
ReduxAction<St> action,
int dispatchCount, {
required bool ini,
});
}
Parameters
action: The dispatched action instancedispatchCount: Sequential number of this dispatchini:truewhen action starts (INI phase),falsewhen it ends (END phase)
Observation Phases
INI Phase: Action dispatch begins. The reducer hasn't modified state yet. Sync reducers may complete during this phase; async reducers start their async process.
END Phase: The reducer has finished and returned the new state. State modifications are now observable.
Important: Receiving an END observation does not guarantee all effects have finished. Async operations that were not awaited may continue running and dispatch additional actions later.
Built-in ConsoleActionObserver
AsyncRedux provides ConsoleActionObserver for development debugging:
var store = Store<AppState>(
initialState: AppState.initialState(),
actionObservers: kReleaseMode ? null : [ConsoleActionObserver()],
);
This prints actions in yellow to the console. Override toString() in your actions to display additional information:
class LoadUserAction extends AppAction {
final String username;
LoadUserAction(this.username);
@override
Future<AppState?> reduce() async {
// ...
}
@override
String toString() => 'LoadUserAction(username: $username)';
}
Using Log.printer for Formatted Output
var store = Store<AppState>(
initialState: AppState.initialState(),
actionObservers: [Log.printer(formatter: Log.verySimpleFormatter)],
);
Custom ActionObserver Implementation
class MyActionObserver implements ActionObserver<AppState> {
@override
void observe(
ReduxAction<AppState> action,
int dispatchCount, {
required bool ini,
}) {
final phase = ini ? 'START' : 'END';
print('[$phase] Action #$dispatchCount: ${action.runtimeType}');
}
}
StateObserver
The StateObserver is notified of all state changes, allowing you to track, log, or record state history.
StateObserver Abstract Class
abstract class StateObserver<St> {
void observe(
ReduxAction<St> action,
St prevState,
St newState,
Object? error,
int dispatchCount,
);
}
Parameters
action: The action that triggered the changeprevState: State before the reducer executednewState: State returned by the reducererror: Null if successful; contains the thrown error otherwisedispatchCount: Sequential dispatch number
Detecting State Changes
Compare states using identical() to detect actual changes:
bool stateChanged = !identical(prevState, newState);
Custom StateObserver for Logging
class StateLogger implements StateObserver<AppState> {
@override
void observe(
ReduxAction<AppState> action,
AppState prevState,
AppState newState,
Object? error,
int dispatchCount,
) {
final changed = !identical(prevState, newState);
print('Action #$dispatchCount: ${action.runtimeType}');
print(' State changed: $changed');
if (error != null) {
print(' Error: $error');
}
}
}
StateObserver for Undo/Redo
A common use case is recording state history for undo/redo functionality:
class UndoRedoObserver implements StateObserver<AppState> {
final List<AppState> _history = [];
int _currentIndex = -1;
final int maxHistorySize;
UndoRedoObserver({this.maxHistorySize = 50});
bool get canUndo => _currentIndex > 0;
bool get canRedo => _currentIndex < _history.length - 1;
@override
void observe(
ReduxAction<AppState> action,
AppState prevState,
AppState newState,
Object? error,
int dispatchCount,
) {
// Skip undo/redo actions to avoid recording navigation
if (action is UndoAction || action is RedoAct
Установить asyncredux-observers в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл asyncredux-observers?
Set up observers for debugging and monitoring. Covers implementing actionObservers for dispatch logging, stateObserver for state change tracking, combining observers with globalWrapError, and using observers for analytics.
Как установить скилл asyncredux-observers?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл asyncredux-observers запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic