Sharing Models via @Environment
Inject a model into the view environment.
Sharing Down Many Levels
Passing a model through every view in between gets tedious. The environment lets deep child views reach it directly.
What the Environment Is
The environment is a shared bag of values flowing down the view tree, so any descendant can read what an ancestor placed there.
All lessons in this course
- From View State to a Model Class
- The @Observable Macro
- @State for Owned Objects
- Sharing Models via @Environment