Member-only story
The Swift Observation Framework Is Great but Not My Cup of Tea
How a new Framework is actually a downgrade
Every couple of years, a new thing hits the SwiftUI ecosystem. This time, it is Observation. But it is not the update I was hoping for.
What Is the Observation Framework?
Observation is a new framework that wants to streamline state updates for our views. While we already had State
and ObservedObject/StateObject
, those weren’t perfect either.
Using iOS17 — at least Apple thinks so — all we need is Environment
, Bindable
and State
. Gone are all the other confusing ways of doing the same thing — managing state.
The new framework brings a couple of improvements. The most important ones:
- Only properties that are actually observed trigger view updates
- Simpler syntax, simplified state management
- Macro-based code generation
- Swift framework, not part of SwiftUI, cross-platform
Especially the performance parts and the cumbersome syntax were a major issue of the old ways of handling state.