struct Bindable
Swift
@propertyWrapper @dynamicMemberLookup struct Bindable<Value> where Value : AnyObject
Projects bindings out of a reference-type model: $model.property.
@State owns view-local storage and cannot be reached from outside the view
tree, which is why state shared with a menubar (LavaApp.run(menu:)) has to
live in an @Observable class instead. This is what gives that class the
same $value ergonomics @State has:
@Bindable var session: TraceLoomSession
…
EditorView(text: $session.rules)
Toggle("Show log", isOn: $session.showLog)
Read session.property directly for a value; use $session.property where
a Binding is wanted. Each projection goes through Binding(_:_:) above,
so it registers its Observation dependency as it is built.
Only a wrapper, deliberately: it owns no storage and adopts none, so
StateTransfer skips it — the model outlives the view struct on its own,
which is the entire point of putting it in a class.
Sources/LavaUI/Bindable.swift:62
Constructors
init(wrappedValue: Value)
Wraps wrappedValue. Called by @Bindable var model = ….
Sources/LavaUI/Bindable.swift:67
Properties
var projectedValue: Bindable<Value> { get }
The wrapper itself, so $model.property goes through the dynamic-member subscript.
Sources/LavaUI/Bindable.swift:72
var wrappedValue: Value
The model the bindings are projected from.
Sources/LavaUI/Bindable.swift:64
Methods
subscript<Subject>(dynamicMember keyPath: ReferenceWritableKeyPath<Value, Subject>) -> Binding<Subject> { get }
A binding to one property of the model: what $model.property returns.
Sources/LavaUI/Bindable.swift:75