ObjectState
@propertyWrapper
public struct ObjectState<O> : DynamicProperty where O : DynamicObject
A property wrapper type that can read ObjectPublisher
changes.
-
Creates an instance that observes
ObjectPublisher
changes and exposes anOptional<ObjectSnapshot<O>>
value.@ObjectState var person: ObjectSnapshot<Person>? init(objectPublisher: ObjectPublisher<Person>) { self._person = .init(objectPublisher) } var body: some View { HStack { AsyncImage(self.person?.$avatarURL) Text(self.person?.$fullName ?? "") } }
Declaration
Swift
public init(_ objectPublisher: ObjectPublisher<O>?)
Parameters
objectPublisher
The
ObjectPublisher
that theObjectState
will observe changes for
-
Declaration
Swift
public mutating func update()