• With the new SwiftUI @Observable macro, are there any cases where ObservableObject would still be a better alternative?

  • Does the new @Observable wrapper automatically apply @MainActor - we've been using MainActor on our ViewModel classes to ensure @Published vars are updated on main.

  • Let’s say we have 3 sections, so first section uses a single property from @Observable class, so whole body will be recomputed or that particular section will be?

  • Regarding an Observable class, what happens if an attribute is modified, but indirectly? For example, in the case of having an attribute that uses getters & setters. Would the view still update automatically?

  • With the old property wrappers, @ObservedObject was used when a view did not own its state (and the ObservedObject was often injected into the view via constructor), while @StateObject was used when a view did own its state (and the StateObject could just be constructed there). How do these ownership models translate to the new @Observable macro? Is it the case that @State is used if the view owns its state, and a plain old property is used if the view doesn't?

  • Follow-up question about data ownership and @Observable! StateObject has an init(wrappedValue:) initializer which can be carefully used for data dependency injection, with all the usual caveats about how it will not be updated if that data changes because it's an autoclosure, etc. Is there an analogous way to inject data for @State data owned by the view? I know there's an init(initialValue:) but I think we've been more strongly warned off from that in the past.

  • Is there a pattern for making struct members @Observable if the struct is provided outside your app? Eg, if I'm importing the struct from a third party library but I still want SwiftUI to reflect changes to its members?

  • From looking at the expanded @Observable macro, it looks like Observation tracks “what is used” but not “who used” (I see nothing about the caller, I expected something like _enclosingInstance…).Yet when I have 2 views, each using a different var from the same class, only the relevant view is updated (I’m using _printChanges to check).Does the @Observable class know not to notify the other view of the change? Or does SwiftUI know not to diff the other view? Something else?How does it work or what am I missing here?

  • In SwiftUI, Core Data objects conform to ObservableObject, so our views can update automatically when the object changes. For example: struct DetailView: View { @ObservedObject var item: Item ... } With Observable replacing ObservableObject/ObservedObject property wrappers, will CoreData objects automatically conform to Observable?

  • Observation seems to bring good performance improvements, as far as I've heard that's due to Observable objects make SwiftUI only recalculate the body of views when observed properties change. But SwiftUI still diffs changes (right?), are there good tips to consider, like if it's better to use many Observable objects vs 1, or If it's ok to nest Observable objects inside Observable objects?