swiftui-observation
Installation
SKILL.md
SwiftUI Observation (iOS 17+)
Overview
The @Observable macro (Observation framework) replaces ObservableObject/@Published. Views automatically track only the properties they actually read, so re-rendering becomes fine-grained instead of invalidating on every @Published change.
When to use
- New SwiftUI view models or app state on iOS 17+
- Migrating off
ObservableObject,@Published,@StateObject,@ObservedObject,@EnvironmentObject - Excess re-renders / performance from coarse
@Publishedinvalidation - Two-way bindings to a reference-type model (
@Bindable)