79607266

Date: 2025-05-05 16:10:01
Score: 1
Natty:
Report link

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

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: pete pan