Looking at the recently updated documentation for @StateObject,, it still shows this pattern when creating a StateObject
in an initializer:
_model = StateObject(wrappedValue: { DataModel(name: name) }())
But isn't the following equivalent, even preferred, since wrappedValue
is marked @autoclosure
?
_model = StateObject(wrappedValue: DataModel(name: name))