https://developer.apple.com/videos/play/wwdc2019/226/
[PlayerView] ---- [true]
Source of Truth
Property Wrapper
Wraps property Access with additional Behavior
@Binding Property Wrapper
Read and write without ownership
Derivable from @State
class PodcastPlayserStore: BindableObject {
var didChange = PassthroughSubject<Void, Never>()
//...
func advance() {
currentEpisode = nextEpisode
currentTime = 0.0
// Notofy subscribers that the palyer changed
didChange.send()
}
}
BindableObject?
struct MyView: View {
@ObjectBinding var model: MyModelObject
...
}
MyView(model: modelInstance)
Environment
Data applicable to an entire hierarchy
Convenience for indirection
Accent color, right-to-left, and more
@State
View - local
Value
Framework Managed
Bindable Object
External
Reference
Developer Managed
@Binding
First class reference to data
Great for reusability
Use $ to derive from source
Limit use if possible
Use derived Binding or value
Prefer Bindable Object for persistence
Example: Button highlighting