Ios state management
Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/ios-state-management
Standards for Combine, Observation, and Reactive Programming. Use when managing state with Combine, @Observable, or reactive patterns in iOS. (triggers: **/*.swift, Observable, @Published, PassthroughSubject, @Observable, @Namespace)From its SKILL.md
npx -y skills add ComeOnOliver/skillshub --skill ios-state-managementAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.9 KB, 408 tokens by cl100k_base, as published. Nobody here has run it
iOS State Management Standards
Priority: P0
Implementation Guidelines
Combine (Reactive States)
- Publishers: Use
@Publishedfor standard state in ViewModels. UsePassthroughSubjectfor one-time navigation or alert events. - Memory Management: Store subscriptions in a
Set<AnyCancellable>. Use.store(in: &cancellables)to prevent memory leaks and ensure they are cleared on deinit. - Operators: Use specific operators like
.debounce,.filter,.map, and.flatMapto handle complex input streams. - Schedulers: Always ensure UI property updates occur on the main thread using
@MainActoror.receive(on: DispatchQueue.main).
Observation Framework (iOS 17+)
@Observable: Use the@Observablemacro for modern, high-performance observation in SwiftUI.- State Properties: In SwiftUI views, use
@Bindablefor two-way bindings with@Observableobjects. - Namespaces: Use
@Namespacefor match-geometry animations and coordinate space tracking.
Unidirectional Data Flow (UDF)
- Input/Output: ViewModels should expose an
Inputenum (events) andOutputstruct (state) to enforce a clear data direction. - ViewState: Prefer a single, exhaustive
ViewStateenum (e.g.,.loading,.success(data),.error(failure)).
Anti-Patterns
- No uncleared subscriptions: Always use .store(in: &cancellables).
- No UI updates on background: Use .receive(on: .main).
- No manual objectWillChange: Use @Published or @Observable.
References
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.