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
Publisherthat emits the new value ofwrappedValueafter it was mutated (usingdidSetsemantics).Declaration
Swift
public let projectedValue: AnyPublisher<Value, Never> -
A
Publisherthat fires wheneverwrappedValuewas mutated. To access the new value ofwrappedValue, accesswrappedValuedirectly, thisPublisheronly 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
PostPublishedproperty wrapper.Declaration
Swift
public init(wrappedValue: Value, emitCurrentValue: Bool = true)Parameters
wrappedValueThe initial value.
emitCurrentValueWhether to emit the current wrapped value when subscribing to
projectValue. WhentruethendidChangeSubjectwill use aCurrentValueSubjectand thus providing the last value. WhenfalsethendidChangeSubjectwill use aPassthroughSubjectinstead and thus only passing new value updates. Defaults totrue.
View on GitHub