Enumeration

Publishers

A namespace for types that serve as publishers.

Declaration

enum Publishers

Overview

The various operators defined as extensions on Publisher implement their functionality as classes or structures that extend this enumeration. For example, the contains(_:) operator returns a Publishers.Contains instance.

Topics

Convenience Publishers

struct Publishers.Sequence

A publisher that publishes a given sequence of elements.

struct Publishers.Catch

A publisher that handles errors from an upstream publisher by replacing the failed publisher with another publisher.

Working with Subscribers

struct Publishers.ReceiveOn

A publisher that delivers elements to its downstream subscriber on a specific scheduler.

struct Publishers.SubscribeOn

A publisher that receives elements from an upstream publisher on a specific scheduler.

Mapping Elements

struct Publishers.TryMap

A publisher that transforms all elements from the upstream publisher with a provided error-throwing closure.

struct Publishers.Map

A publisher that transforms all elements from the upstream publisher with a provided closure.

struct Publishers.MapError

A publisher that converts any failure from the upstream publisher into a new error.

struct Publishers.SetFailureType

A publisher that appears to send a specified failure type.

Filtering Elements

struct Publishers.CompactMap

A publisher that republishes all non-nil results of calling a closure with each received element.

struct Publishers.Filter

A publisher that republishes all elements that match a provided closure.

struct Publishers.RemoveDuplicates

A publisher that publishes only elements that don’t match the previous element.

struct Publishers.ReplaceEmpty

A publisher that replaces an empty stream with a provided element.

struct Publishers.ReplaceError

A publisher that replaces any errors in the stream with a provided element.

struct Publishers.TryCompactMap

A publisher that republishes all non-nil results of calling an error-throwing closure with each received element.

struct Publishers.TryFilter

A publisher that republishes all elements that match a provided error-throwing closure.

struct Publishers.TryRemoveDuplicates

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

Reducing Elements

struct Publishers.Collect

A publisher that buffers items.

struct Publishers.CollectByCount

A publisher that buffers a maximum number of items.

struct Publishers.CollectByTime

A publisher that buffers and periodically publishes its items.

enum Publishers.TimeGroupingStrategy

A strategy for collecting received elements.

struct Publishers.IgnoreOutput

A publisher that ignores all upstream elements, but passes along a completion state (finish or failed).

struct Publishers.Reduce

A publisher that applies a closure to all received elements and produces an accumulated value when the upstream publisher finishes.

struct Publishers.TryReduce

A publisher that applies an error-throwing closure to all received elements and produces an accumulated value when the upstream publisher finishes.

Applying Mathematical Operations on Elements

struct Publishers.Comparison

A publisher that republishes items from another publisher only if each new item is in increasing order from the previously-published item.

struct Publishers.TryComparison

A publisher that republishes items from another publisher only if each new item is in increasing order from the previously-published item, and fails if the ordering logic throws an error.

struct Publishers.Count

A publisher that publishes the number of elements received from the upstream publisher.

Applying Matching Criteria to Elements

struct Publishers.TryAllSatisfy

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

struct Publishers.AllSatisfy

A publisher that publishes a single Boolean value that indicates whether all received elements pass a given predicate.

struct Publishers.Contains

A publisher that emits a Boolean value when a specified element is received from its upstream publisher.

struct Publishers.ContainsWhere

A publisher that emits a Boolean value upon receiving an element that satisfies the predicate closure.

struct Publishers.TryContainsWhere

A publisher that emits a Boolean value upon receiving an element that satisfies the throwing predicate closure.

Applying Sequence Operations to Elements

struct Publishers.FirstWhere

A publisher that only publishes the first element of a stream to satisfy a predicate closure.

struct Publishers.LastWhere

A publisher that only publishes the last element of a stream that satisfies a predicate closure, once the stream finishes.

struct Publishers.DropUntilOutput

A publisher that ignores elements from the upstream publisher until it receives an element from second publisher.

struct Publishers.DropWhile

A publisher that omits elements from an upstream publisher until a given closure returns false.

struct Publishers.TryDropWhile

A publisher that omits elements from an upstream publisher until a given error-throwing closure returns false.

struct Publishers.Concatenate

A publisher that emits all of one publisher’s elements before those from another publisher.

struct Publishers.Drop

A publisher that omits a specified number of elements before republishing later elements.

struct Publishers.PrefixWhile

A publisher that republishes elements while a predicate closure indicates publishing should continue.

struct Publishers.First

A publisher that publishes the first element of a stream, then finishes.

struct Publishers.Last

A publisher that only publishes the last element of a stream, after the stream finishes.

struct Publishers.TryFirstWhere

A publisher that only publishes the first element of a stream to satisfy a throwing predicate closure.

struct Publishers.TryLastWhere

A publisher that only publishes the last element of a stream that satisfies a error-throwing predicate closure, once the stream finishes.

struct Publishers.TryPrefixWhile

A publisher that republishes elements while an error-throwing predicate closure indicates publishing should continue.

struct Publishers.Output

A publisher that publishes elements specified by a range in the sequence of published elements.

Combining Elements from Multiple Publishers

struct Publishers.CombineLatest

A publisher that receives and combines the latest elements from two publishers.

struct Publishers.CombineLatest3

A publisher that receives and combines the latest elements from three publishers.

struct Publishers.CombineLatest4

A publisher that receives and combines the latest elements from four publishers.

struct Publishers.Merge

A publisher created by applying the merge function to two upstream publishers.

struct Publishers.Merge3

A publisher created by applying the merge function to three upstream publishers.

struct Publishers.Merge4

A publisher created by applying the merge function to four upstream publishers.

struct Publishers.Merge5

A publisher created by applying the merge function to five upstream publishers.

struct Publishers.Merge6

A publisher created by applying the merge function to six upstream publishers.

struct Publishers.Merge7

A publisher created by applying the merge function to seven upstream publishers.

struct Publishers.Merge8

A publisher created by applying the merge function to eight upstream publishers.

struct Publishers.Zip

A publisher created by applying the zip function to two upstream publishers.

struct Publishers.Zip3

A publisher created by applying the zip function to three upstream publishers.

struct Publishers.Zip4

A publisher created by applying the zip function to four upstream publishers.

Handling Errors

struct Publishers.AssertNoFailure

A publisher that raises a fatal error upon receiving any failure, and otherwise republishes all received input.

struct Publishers.Catch

A publisher that handles errors from an upstream publisher by replacing the failed publisher with another publisher.

struct Publishers.TryCatch

A publisher that handles errors from an upstream publisher by replacing the failed publisher with another publisher or producing a new error.

struct Publishers.Retry

A publisher that attempts to recreate its subscription to a failed upstream publisher.

Adapting Publisher Types

struct Publishers.SwitchToLatest

A publisher that “flattens” nested publishers.

Controlling Timing

struct Publishers.Debounce

A publisher that publishes elements only after a specified time interval elapses between events.

struct Publishers.Delay

A publisher that delays delivery of elements and completion to the downstream receiver.

struct Publishers.MeasureInterval

A publisher that measures and emits the time interval between events received from an upstream publisher.

struct Publishers.Throttle

A publisher that publishes either the most-recent or first element published by the upstream publisher in a specified time interval.

Creating Reference-type Publishers

class Publishers.Share

A publisher implemented as a class, which otherwise behaves like its upstream publisher.

Identifying Properties with Key Paths

struct Publishers.MapKeyPath

A publisher that publishes the value of a key path.

struct Publishers.MapKeyPath2

A publisher that publishes the values of two key paths as a tuple.

struct Publishers.MapKeyPath3

A publisher that publishes the values of three key paths as a tuple.

Using Explicit Publisher Connections

class Publishers.Autoconnect

A publisher that automatically connects and disconnects from this connectable publisher.

Working with Multiple Subscribers

class Publishers.Multicast

A publisher that uses a subject to deliver elements to multiple subscribers.

Buffering Elements

struct Publishers.Buffer

A publisher that buffers elements from an upstream publisher.

enum Publishers.BufferingStrategy

A strategy for handling exhaustion of a buffer’s capacity.

enum Publishers.PrefetchStrategy

A strategy for filling a buffer.

Adding Explicit Connectability

struct Publishers.MakeConnectable

A publisher that provides explicit connectability to another publisher.

Debugging

struct Publishers.Breakpoint

A publisher that raises a debugger signal when a provided closure needs to stop the process in the debugger.

struct Publishers.HandleEvents

A publisher that performs the specified closures when publisher events occur.

struct Publishers.Print

A publisher that prints log messages for all publishing events, optionally prefixed with a given string.

See Also

Publishers

protocol Publisher

Declares that a type can transmit a sequence of values over time.

Beta
struct AnyPublisher

A type-erasing publisher.

Beta
protocol ConnectablePublisher

A publisher that provides an explicit means of connecting and canceling publication.

Beta
struct Published

A type that publishes a property marked with an attribute.

Beta
protocol Cancellable

A protocol indicating that an activity or action supports cancellation.

Beta
class AnyCancellable

A type-erasing cancellable object that executes a provided closure when canceled.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software