Generic Structure


A Combine publisher that produces a new element whenever the observed value changes.


struct KeyValueObservingPublisher<Subject, Value> where Subject : NSObject


Use this publisher to integrate a property that’s compliant with key-value observing into a Combine publishing chain. You can create a publisher of this type with the NSObject instance method publisher(for:options:), passing in the key path and a set of NSKeyValueObservingOptions.


Creating a KVO Publisher

init(object: Subject, keyPath: KeyPath<Subject, Value>, options: NSKeyValueObservingOptions)

Creates a key-value observing publisher for the given combination of object and key path, using publishing behavior options you provide.

Inspecting KVO Publisher Properties

let object: Subject

The object that contains the property to publish.

let keyPath: KeyPath<Subject, Value>

The key path, relative to the object receiving this message, of the property to publish.

let options: NSKeyValueObservingOptions

Options that determine which elements the publisher produces.


Conforms To

See Also