Integrate model with binding system
This commit is contained in:
parent
23eba70702
commit
e551fc078a
@ -69,6 +69,20 @@ public struct ModelData {
|
|||||||
|
|
||||||
extension Model {
|
extension Model {
|
||||||
|
|
||||||
|
/// Get the value as a binding using the `$` prefix.
|
||||||
|
public var binding: Binding<Self> {
|
||||||
|
.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.
|
/// Set the model up.
|
||||||
///
|
///
|
||||||
/// At the point this function gets called, the model data is available.
|
/// At the point this function gets called, the model data is available.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user