From the answers it seems like I should be doing:
import Foundation
import SwiftUI
@Observable class MyBindings2 {
var isDisabled:Bool = false
}
struct ContentView: View {
@Bindable var mb:MyBindings2
func action() {
mb.isDisabled = true
Task {
try await Task.sleep(nanoseconds: 1_000_000_000)
mb.isDisabled = false
}
}
var body: some View {
VStack {
Button(action:action){Text("Click Me")}.padding(10)
Button(action:action){Text("or Me")}.padding(10)
Button(action:action){Text("or Maybe Me")}.padding(10)
Text(String(mb.isDisabled))
Text("^^^")
Text("at some point this is false but the View is disabled")
}.disabled(mb.isDisabled)
}
}
I am still trying to convert all of my code to this setup, and since the error is intermittent, I guess I have some testing to do. Thanks to all