SE-0395: Observability

@Philippe_Hausler, thank you.

I want to understand the granularity of this. For example If it was:

@Observable final class Model {
    struct S {
        var related = 0
        var unrelated = 0
    }
    var state = S()
}
...
struct ContentView: View {
    @State private var model = Model()
    
    var body: some View {
        bodyCount += 1
        return VStack {
            Text(String(model.state.related))
        }
    }
}

would the body be recalculated on state.unrelated changes or only on state.related changes?

Secondly, if I set state.related variable to the same value, would it cause body recalculation or not?

3 Likes