Asyncredux state access

From marcglasberg/async_redux · View interactive version

Asyncredux state access is an AI agent skill from the GitHub repository marcglasberg/async_redux. Read store state in AsyncRedux widgets using context.select and context.read, including multiple fields, callbacks, and initState.

How to use this skill

Skill file

Read store state in widgets

Reuse the app's typed BuildContext extension. If it is missing, define

select<R>(R Function(AppState) selector) using getSelect<AppState, R>(selector)

and AppState read() using getRead<AppState>().

values that drive the UI. Select the smallest useful value. For several values,

use separate selections or a Dart record.

subscription. When a callback needs fresh state, read it inside the callback.

context.select outside other selectors. Select list data in the widget's build

and pass it to item builders.

This widget uses AppState and the extension from the setup skill.

class CounterSummary extends StatelessWidget {
  const CounterSummary({required this.onInspect, super.key});

  final ValueChanged<int> onInspect;

  @override
  Widget build(BuildContext context) {
    final (:counter, :caption) = context.select(
      (st) => (counter: st.counter, caption: st.caption),
    );

    return TextButton(
      onPressed: () => onInspect(context.read().counter),
      child: Text('$caption: $counter'),
    );
  }
}

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.