인터페이스는 현지화되어 있으며, Skill 소개와 설명 문서는 선택한 언어로 AI가 자동 번역합니다. 코드·명령어·경로·전문 용어는 원문을 유지하며 원작자 문서가 우선합니다.
Skills 둘러보기
생산성 및 협업 · SKILL.md

ios-state-management

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.

Independent GitHub snapshot · Automated classification · Original documentation governs

Skill 문서

GitHub

name: ios-state-management description: Implement reactive state with Combine, Observation framework, and UDF patterns. Use when implementing state management with Combine, @Observable, or reactive patterns in iOS. metadata: triggers: files: - '**/*.swift' keywords: - Observable - "@Published" - PassthroughSubject - "@Observable" - "@Namespace"

iOS State Management

Priority: P0 (CRITICAL)

Implementation Workflow

  1. Choose observation approach — Use @Observable (iOS 17+) for modern SwiftUI; Combine with @Published for UIKit or broader compatibility.
  2. Expose state clearly — Use UDF pattern: ViewModel exposes Input enum (events) and Output struct (state).
  3. Manage subscriptions — Store Combine subscriptions in Set<AnyCancellable> with .store(in: &cancellables).
  4. Dispatch to main thread — Use @MainActor or .receive(on: DispatchQueue.main) for UI updates.
  5. Use exhaustive ViewState — Prefer single ViewState enum (.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 .receive(on: .main) or @MainActor
  • No Manual objectWillChange.send(): Use @Published or @Observable instead

References

저장한 Skills