diff --git a/Sources/Model/Data Flow/Model.swift b/Sources/Model/Data Flow/Model.swift index 5b72fde..5ab11a2 100644 --- a/Sources/Model/Data Flow/Model.swift +++ b/Sources/Model/Data Flow/Model.swift @@ -69,6 +69,20 @@ public struct ModelData { extension Model { + /// Get the value as a binding using the `$` prefix. + public var binding: Binding { + .init { + getModel() + } set: { newValue in + guard let data = model else { + return + } + StateManager.setState(id: data.id, value: newValue) + StateManager.updateState(id: data.id) + StateManager.updateViews(force: data.force) + } + } + /// Set the model up. /// /// At the point this function gets called, the model data is available.