Fix observing models not always working
This commit is contained in:
parent
e133b7b8b7
commit
e490cf2b82
@ -113,11 +113,9 @@ extension App {
|
|||||||
withObservationTracking {
|
withObservationTracking {
|
||||||
_ = scene
|
_ = scene
|
||||||
} onChange: {
|
} onChange: {
|
||||||
Task {
|
StateManager.updateState(id: app.storage.stateStorage.first?.value.id ?? .init())
|
||||||
StateManager.updateState(id: app.storage.stateStorage.first?.value.id ?? .init())
|
StateManager.updateViews()
|
||||||
StateManager.updateViews()
|
observe()
|
||||||
observe()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -85,11 +85,9 @@ struct StateWrapper: ConvenienceWidget {
|
|||||||
withObservationTracking {
|
withObservationTracking {
|
||||||
_ = content()
|
_ = content()
|
||||||
} onChange: {
|
} onChange: {
|
||||||
Task {
|
StateManager.updateState(id: storage.state.first?.value.id ?? .init())
|
||||||
StateManager.updateState(id: storage.state.first?.value.id ?? .init())
|
StateManager.updateViews()
|
||||||
StateManager.updateViews()
|
observe(storage: storage)
|
||||||
observe(storage: storage)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,14 +60,15 @@ struct DemoView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(macOS 14, *)
|
||||||
struct TestView: View {
|
struct TestView: View {
|
||||||
|
|
||||||
@State private var test = "Label"
|
@State private var test = TestModel()
|
||||||
|
|
||||||
var view: Body {
|
var view: Body {
|
||||||
Backend2.TestWidget4()
|
Backend2.TestWidget4()
|
||||||
Backend1.Button(test) {
|
Backend1.Button(test.test) {
|
||||||
test = "\(Int.random(in: 1...10))"
|
test.test = "\(Int.random(in: 1...10))"
|
||||||
}
|
}
|
||||||
Backend1.Menu("Hi") {
|
Backend1.Menu("Hi") {
|
||||||
Backend1.Menu("World") {
|
Backend1.Menu("World") {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user