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