Class

ObservableObjectPublisher

A publisher that publishes changes from observable objects.

Declaration

final class ObservableObjectPublisher

Topics

Type Aliases

typealias ObservableObjectPublisher.Failure

The type of errors this publisher might produce.

typealias ObservableObjectPublisher.Output

The type of elements published by this publisher.

Initializers

init()

Creates an observable object publisher instance.

Instance Methods

func allSatisfy((Void) -> Bool) -> Publishers.AllSatisfy<ObservableObjectPublisher>

Publishes a single Boolean value that indicates whether all received elements pass a given predicate.

func assertNoFailure(String, file: StaticString, line: UInt) -> Publishers.AssertNoFailure<ObservableObjectPublisher>

Raises a fatal error when its upstream publisher fails, and otherwise republishes all received input.

func assign<Root>(to: ReferenceWritableKeyPath<Root, Void>, on: Root) -> AnyCancellable

Assigns a publisher’s output to a property of an object.

func `catch`<P>((Never) -> P) -> Publishers.Catch<ObservableObjectPublisher, P>

Handles errors from an upstream publisher by replacing it with another publisher.

func collect() -> Publishers.Collect<ObservableObjectPublisher>

Collects all received elements, and emits a single array of the collection when the upstream publisher finishes.

func collect(Int) -> Publishers.CollectByCount<ObservableObjectPublisher>

Collects up to the specified number of elements, and then emits a single array of the collection.

func combineLatest<P>(P) -> Publishers.CombineLatest<ObservableObjectPublisher, P>

Subscribes to an additional publisher and publishes a tuple upon receiving output from either publisher.

func combineLatest<P, Q>(P, Q) -> Publishers.CombineLatest3<ObservableObjectPublisher, P, Q>

Subscribes to two additional publishers and publishes a tuple upon receiving output from any of the publishers.

func combineLatest<P, T>(P, (Void, P.Output) -> T) -> Publishers.Map<Publishers.CombineLatest<ObservableObjectPublisher, P>, T>

Subscribes to an additional publisher and invokes a closure upon receiving output from either publisher.

func combineLatest<P, Q, R>(P, Q, R) -> Publishers.CombineLatest4<ObservableObjectPublisher, P, Q, R>

Subscribes to three additional publishers and publishes a tuple upon receiving output from any of the publishers.

func combineLatest<P, Q, T>(P, Q, (Void, P.Output, Q.Output) -> T) -> Publishers.Map<Publishers.CombineLatest3<ObservableObjectPublisher, P, Q>, T>

Subscribes to two additional publishers and invokes a closure upon receiving output from any of the publishers.

func combineLatest<P, Q, R, T>(P, Q, R, (Void, P.Output, Q.Output, R.Output) -> T) -> Publishers.Map<Publishers.CombineLatest4<ObservableObjectPublisher, P, Q, R>, T>

Subscribes to three additional publishers and invokes a closure upon receiving output from any of the publishers.

func compactMap<T>((Void) -> T?) -> Publishers.CompactMap<ObservableObjectPublisher, T>

Calls a closure with each received element and publishes any returned optional that has a value.

func contains(where: (Void) -> Bool) -> Publishers.ContainsWhere<ObservableObjectPublisher>

Publishes a Boolean value upon receiving an element that satisfies the predicate closure.

func count() -> Publishers.Count<ObservableObjectPublisher>

Publishes the number of elements received from the upstream publisher.

func drop<P>(untilOutputFrom: P) -> Publishers.DropUntilOutput<ObservableObjectPublisher, P>

Ignores elements from the upstream publisher until it receives an element from a second publisher.

func drop(while: (Void) -> Bool) -> Publishers.DropWhile<ObservableObjectPublisher>

Omits elements from the upstream publisher until a given closure returns false, before republishing all remaining elements.

func dropFirst(Int) -> Publishers.Drop<ObservableObjectPublisher>

Omits the specified number of elements before republishing subsequent elements.

func eraseToAnyPublisher() -> AnyPublisher<Void, Never>

Wraps this publisher with a type eraser.

func filter((Void) -> Bool) -> Publishers.Filter<ObservableObjectPublisher>

Republishes all elements that match a provided closure.

func first() -> Publishers.First<ObservableObjectPublisher>

Publishes the first element of a stream, then finishes.

func first(where: (Void) -> Bool) -> Publishers.FirstWhere<ObservableObjectPublisher>

Publishes the first element of a stream to satisfy a predicate closure, then finishes.

func flatMap<T, P>(maxPublishers: Subscribers.Demand, (Void) -> P) -> Publishers.FlatMap<P, ObservableObjectPublisher>

Transforms all elements from an upstream publisher into a new or existing publisher.

func ignoreOutput() -> Publishers.IgnoreOutput<ObservableObjectPublisher>

Ingores all upstream elements, but passes along a completion state (finished or failed).

func last() -> Publishers.Last<ObservableObjectPublisher>

Publishes only the last element of a stream, after the stream finishes.

func last(where: (Void) -> Bool) -> Publishers.LastWhere<ObservableObjectPublisher>

Publishes only the last element of a stream that satisfies a predicate closure, after the stream finishes.

func map<T>((Void) -> T) -> Publishers.Map<ObservableObjectPublisher, T>

Transforms all elements from the upstream publisher with a provided closure.

func mapError<E>((Never) -> E) -> Publishers.MapError<ObservableObjectPublisher, E>

Converts any failure from the upstream publisher into a new error.

func max(by: (Void, Void) -> Bool) -> Publishers.Comparison<ObservableObjectPublisher>

Publishes the maximum value received from the upstream publisher, using the provided ordering closure.

func measureInterval<S>(using: S, options: S.SchedulerOptions?) -> Publishers.MeasureInterval<ObservableObjectPublisher, S>

Measures and emits the time interval between events received from an upstream publisher.

func merge(with: ObservableObjectPublisher) -> Publishers.MergeMany<ObservableObjectPublisher>

Combines elements from this publisher with those from another publisher of the same type, delivering an interleaved sequence of elements.

func merge<B, C>(with: B, C) -> Publishers.Merge3<ObservableObjectPublisher, B, C>

Combines elements from this publisher with those from two other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D>(with: B, C, D) -> Publishers.Merge4<ObservableObjectPublisher, B, C, D>

Combines elements from this publisher with those from three other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E>(with: B, C, D, E) -> Publishers.Merge5<ObservableObjectPublisher, B, C, D, E>

Combines elements from this publisher with those from four other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E, F>(with: B, C, D, E, F) -> Publishers.Merge6<ObservableObjectPublisher, B, C, D, E, F>

Combines elements from this publisher with those from five other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E, F, G>(with: B, C, D, E, F, G) -> Publishers.Merge7<ObservableObjectPublisher, B, C, D, E, F, G>

Combines elements from this publisher with those from six other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E, F, G, H>(with: B, C, D, E, F, G, H) -> Publishers.Merge8<ObservableObjectPublisher, B, C, D, E, F, G, H>

Combines elements from this publisher with those from seven other publishers, delivering an interleaved sequence of elements.

func min(by: (Void, Void) -> Bool) -> Publishers.Comparison<ObservableObjectPublisher>

Publishes the minimum value received from the upstream publisher, after it finishes.

func multicast<S>(() -> S) -> Publishers.Multicast<ObservableObjectPublisher, S>

Applies a closure to create a subject that delivers elements to subscribers.

func multicast<S>(subject: S) -> Publishers.Multicast<ObservableObjectPublisher, S>

Provides a subject to deliver elements to multiple subscribers.

func output(at: Int) -> Publishers.Output<ObservableObjectPublisher>

Publishes a specific element, indicated by its index in the sequence of published elements.

func output<R>(in: R) -> Publishers.Output<ObservableObjectPublisher>

Publishes elements specified by their range in the sequence of published elements.

func prefix(Int) -> Publishers.Output<ObservableObjectPublisher>

Republishes elements up to the specified maximum count.

func prefix(while: (Void) -> Bool) -> Publishers.PrefixWhile<ObservableObjectPublisher>

Republishes elements while a predicate closure indicates publishing should continue.

func receive<S>(on: S, options: S.SchedulerOptions?) -> Publishers.ReceiveOn<ObservableObjectPublisher, S>

Specifies the scheduler on which to receive elements from the publisher.

func reduce<T>(T, (T, Void) -> T) -> Publishers.Reduce<ObservableObjectPublisher, T>

Applies a closure that accumulates each element of a stream and publishes a final result upon completion.

func removeDuplicates(by: (Void, Void) -> Bool) -> Publishers.RemoveDuplicates<ObservableObjectPublisher>

Publishes only elements that don’t match the previous element, as evaluated by a provided closure.

func replaceError(with: Void) -> Publishers.ReplaceError<ObservableObjectPublisher>

Replaces any errors in the stream with the provided element.

func replaceNil<T>(with: T) -> Publishers.Map<ObservableObjectPublisher, T>

Replaces nil elements in the stream with the provided element.

func retry(Int) -> Publishers.Retry<ObservableObjectPublisher>

Attempts to recreate a failed subscription with the upstream publisher using a specified number of attempts to establish the connection.

func scan<T>(T, (T, Void) -> T) -> Publishers.Scan<ObservableObjectPublisher, T>

Transforms elements from the upstream publisher by providing the current element to a closure along with the last value returned by the closure.

func share() -> Publishers.Share<ObservableObjectPublisher>

Returns a publisher as a class instance.

func sink(receiveValue: ((Void) -> Void)) -> AnyCancellable

Attaches a subscriber with closure-based behavior to a publisher that never fails.

func subscribe<S>(S) -> AnyCancellable

Attaches the specified subject to this publisher.

func subscribe<S>(S)

Attaches the specified subscriber to this publisher.

func subscribe<S>(on: S, options: S.SchedulerOptions?) -> Publishers.SubscribeOn<ObservableObjectPublisher, S>

Specifies the scheduler on which to perform subscribe, cancel, and request operations.

func throttle<S>(for: S.SchedulerTimeType.Stride, scheduler: S, latest: Bool) -> Publishers.Throttle<ObservableObjectPublisher, S>

Publishes either the most-recent or first element published by the upstream publisher in the specified time interval.

func timeout<S>(S.SchedulerTimeType.Stride, scheduler: S, options: S.SchedulerOptions?, customError: (() -> Never)?) -> Publishers.Timeout<ObservableObjectPublisher, S>

Terminates publishing if the upstream publisher exceeds the specified time interval without producing an element.

func tryAllSatisfy((Void) -> Bool) -> Publishers.TryAllSatisfy<ObservableObjectPublisher>

Publishes a single Boolean value that indicates whether all received elements pass a given error-throwing predicate.

func tryCatch<P>((Never) -> P) -> Publishers.TryCatch<ObservableObjectPublisher, P>

Handles errors from an upstream publisher by replacing it with another publisher or an error.

func tryCompactMap<T>((Void) -> T?) -> Publishers.TryCompactMap<ObservableObjectPublisher, T>

Calls an error-throwing closure with each received element and publishes any returned optional that has a value.

func tryContains(where: (Void) -> Bool) -> Publishers.TryContainsWhere<ObservableObjectPublisher>

Publishes a Boolean value upon receiving an element that satisfies the throwing predicate closure.

func tryDrop(while: (Void) -> Bool) -> Publishers.TryDropWhile<ObservableObjectPublisher>

Omits elements from the upstream publisher until an error-throwing closure returns false, before republishing all remaining elements.

func tryFilter((Void) -> Bool) -> Publishers.TryFilter<ObservableObjectPublisher>

Republishes all elements that match a provided error-throwing closure.

func tryFirst(where: (Void) -> Bool) -> Publishers.TryFirstWhere<ObservableObjectPublisher>

Publishes the first element of a stream to satisfy a throwing predicate closure, then finishes.

func tryLast(where: (Void) -> Bool) -> Publishers.TryLastWhere<ObservableObjectPublisher>

Publishes only the last element of a stream that satisfies an error-throwing predicate closure, after the stream finishes.

func tryMap<T>((Void) -> T) -> Publishers.TryMap<ObservableObjectPublisher, T>

Transforms all elements from the upstream publisher with a provided error-throwing closure.

func tryMax(by: (Void, Void) -> Bool) -> Publishers.TryComparison<ObservableObjectPublisher>

Publishes the maximum value received from the upstream publisher, using the provided error-throwing closure to order the items.

func tryMin(by: (Void, Void) -> Bool) -> Publishers.TryComparison<ObservableObjectPublisher>

Publishes the minimum value received from the upstream publisher, using the provided error-throwing closure to order the items.

func tryPrefix(while: (Void) -> Bool) -> Publishers.TryPrefixWhile<ObservableObjectPublisher>

Republishes elements while a error-throwing predicate closure indicates publishing should continue.

func tryReduce<T>(T, (T, Void) -> T) -> Publishers.TryReduce<ObservableObjectPublisher, T>

Applies an error-throwing closure that accumulates each element of a stream and publishes a final result upon completion.

func tryRemoveDuplicates(by: (Void, Void) -> Bool) -> Publishers.TryRemoveDuplicates<ObservableObjectPublisher>

Publishes only elements that don’t match the previous element, as evaluated by a provided error-throwing closure.

func tryScan<T>(T, (T, Void) -> T) -> Publishers.TryScan<ObservableObjectPublisher, T>

Transforms elements from the upstream publisher by providing the current element to an error-throwing closure along with the last value returned by the closure.

func zip<P>(P) -> Publishers.Zip<ObservableObjectPublisher, P>

Combines elements from another publisher and deliver pairs of elements as tuples.

func zip<P, T>(P, (Void, P.Output) -> T) -> Publishers.Map<Publishers.Zip<ObservableObjectPublisher, P>, T>

Combines elements from another publisher and delivers a transformed output.

func zip<P, Q>(P, Q) -> Publishers.Zip3<ObservableObjectPublisher, P, Q>

Combines elements from two other publishers and delivers groups of elements as tuples.

func zip<P, Q, R>(P, Q, R) -> Publishers.Zip4<ObservableObjectPublisher, P, Q, R>

Combines elements from three other publishers and delivers groups of elements as tuples.

Relationships

Conforms To

See Also

Observable Objects

protocol ObservableObject

A type of object with a publisher that emits before the object has changed.