Agent-skills-standard ios-state-management
Implement reactive state with Combine, Observation framework, and UDF patterns. Use when implementing state management with Combine, @Observable, or reactive patterns in iOS. (triggers: **/*.swift, Observable, @Published, PassthroughSubject, @Observable, @Namespace)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/ios/ios-state-management" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-ios-state-management && rm -rf "$T"
manifest:
skills/ios/ios-state-management/SKILL.mdsource content
iOS State Management
Priority: P0
Implementation Workflow
- Choose observation approach — Use
(iOS 17+) for modern SwiftUI;@Observable
withCombine
for UIKit or broader compatibility.@Published - Expose state clearly — Use UDF pattern: ViewModel exposes
enum (events) andInput
struct (state).Output - Manage subscriptions — Store Combine subscriptions in
withSet<AnyCancellable>
..store(in: &cancellables) - Dispatch to main thread — Use
or@MainActor
for UI updates..receive(on: DispatchQueue.main) - Use exhaustive ViewState — Prefer single
enum (ViewState
,.loading
,.success(data)
)..error(failure)
See Combine and Observation framework examples
Anti-Patterns
- No Uncleared Subscriptions: Always use
.store(in: &cancellables) - No Background UI Updates: Use
or.receive(on: .main)@MainActor - No Manual
: UseobjectWillChange.send()
or@Published
instead@Observable