← ClaudeAtlas

bloc-patternlisted

GM Bloc state management patterns — part/part-of structure, sub-state unions (idle/loading/error/done), modular (Failure) vs non-modular (Result switch)
ghozimahdi/gm-aiagent-plugins · ★ 0 · AI & Automation · score 70
Install: claude install-skill ghozimahdi/gm-aiagent-plugins
Resolve `UFIL_ROOT` to the plugin root containing this skill. Claude Code may provide `CLAUDE_PLUGIN_ROOT`; Codex can resolve it from the installed skill path. ## Bloc Patterns (GM Standard) ### File Structure — `part` / `part of` (3 files per bloc) The bloc file is the main library. Event and state files use `part of`: ``` blocs/ └── property_detail/ ├── property_detail_bloc.dart ← main file (has part directives) ├── property_detail_event.dart ← part of bloc └── property_detail_state.dart ← part of bloc ``` ### Events — `@freezed abstract class`, `part of` bloc ```dart // property_detail_event.dart part of 'property_detail_bloc.dart'; @freezed abstract class PropertyDetailEvent with _$PropertyDetailEvent { const factory PropertyDetailEvent.init({required String propertyId}) = _InitEvent; const factory PropertyDetailEvent.refresh() = _RefreshEvent; const factory PropertyDetailEvent.delete() = _DeleteEvent; } ``` ### States — sub-state unions per async action (NOT flat bool flags) #### Non-Modular — error carries `Failure` ```dart // property_detail_state.dart part of 'property_detail_bloc.dart'; @freezed abstract class PropertyDetailState with _$PropertyDetailState { const factory PropertyDetailState({ @Default(GetPropertyDetailState.idle()) GetPropertyDetailState propertyDetailState, @Default(DeletePropertyDetailState.idle()) DeletePropertyDetailState deletePropertyDetailState, }) = _PropertyDetailState; } @freezed abstract cl