PostPublished
@propertyWrapper
public class PostPublished<Value>
A type that publishes changes about its wrappedValue
property after the property has changed (using didSet
semantics).
Reimplementation of Combine.Published
, which uses willSet
semantics.
Source: https://stackoverflow.com/questions/69978018/observe-change-on-a-published-var-in-swift-combine-after-didset
-
A
Publisher
that emits the new value ofwrappedValue
after it was mutated (usingdidSet
semantics).Declaration
Swift
public let projectedValue: AnyPublisher<Value, Never>
-
A
Publisher
that fires wheneverwrappedValue
was mutated. To access the new value ofwrappedValue
, accesswrappedValue
directly, thisPublisher
only signals a change, it doesn’t contain the changed value.Declaration
Swift
public let valueDidChange: AnyPublisher<Void, Never>
-
Undocumented
Declaration
Swift
public var wrappedValue: Value { get set }
-
Initializer for a
PostPublished
property wrapper.Declaration
Swift
public init(wrappedValue: Value, emitCurrentValue: Bool = true)
Parameters
wrappedValue
The initial value.
emitCurrentValue
Whether to emit the current wrapped value when subscribing to
projectValue
. Whentrue
thendidChangeSubject
will use aCurrentValueSubject
and thus providing the last value. Whenfalse
thendidChangeSubject
will use aPassthroughSubject
instead and thus only passing new value updates. Defaults totrue
.