> 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)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/ios-state-management?format=md"iOS State Management Standards
Priority: P0
Implementation Guidelines
Combine (Reactive)
- Publishers: Use
@Publishedfor state in ViewModels. UsePassthroughSubjectfor one-time events (Transitions/Alerts). - Memory Management: Store subscriptions in a
Set<AnyCancellable>. Ensure they are cleared on deinit. - Operators: Use operators like
.debounce,.filter,.map, and.flatMapto transform input stream. - Schedulers: Always prefix UI property updates with
@MainActoror use.receive(on: DispatchQueue.main).
Observation Framework (iOS 17+)
- @Observable: Use for modern, macro-based observation. Replace
ObservableObjectin SwiftUI apps. - Binding: Use
$statefor two-way bindings in SwiftUI. No boilerplateobjectWillChangecalls.
Best Practices
- ViewState Unification: Prefer a single
Stateenum or struct (Unidirectional) for complex screens. - Avoid Over-Reactive: Don't use Combine for simple local flags. Use standard
@Stateor variables.
Anti-Patterns
- Subscription Leaks:
**No uncleared subscriptions**: Always use .store(in: &cancellables). - Main Thread Violation:
**No UI updates on Background**: Use .receive(on: .main). - Manual objectWillChange:
**No manual notifications**: Use @Published or @Observable.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)