Converting from ObservableObject
to @Observable
macro, an initial value is required but initializing from init
fails:
@Observable final class ViewModel {
var foo: Foo // ❌ @Observable requires property 'foo' to have an initial value (from macro 'Observable')
init(foo: Foo) {
self.foo = foo
}
}
The macro seemingly requires initialization twice (with an initial value that will be immediately discarded). Is there a reasonable solution to this using classes for view models?