What problem does it solve?
Building and maintaining stateful ViewModels for SwiftUI apps can be verbose and error-prone. This skill provides a ready-to-use pattern to encapsulate view state, coordinate between views and use cases, and enforce testable, predictable behavior with minimal boilerplate.
Core Features & Use Cases
- ViewState pattern for local state management with an internal, non-public state that supports idle, loading, loaded, and error states.
- Structured ViewModel patterns for detail views (with navigation) and list views (with optional navigation and tracking), including conventions for public lifecycle methods like didAppear() and didTapOnRetryButton().
- Protocol-based dependency injection for UseCases, NavigatorContract, and TrackerContract to promote testability and modularity, while keeping navigation and tracking concerns encapsulated within dedicated components.
- Testing guidance and example Integrations for ensuring state transitions, navigation, and tracking behaviors are verifiable.
Quick Start
Create a new ViewModel by applying the ViewState pattern and the recommended file structure for a feature.