TechnologiesFoundation, System & Concurrency

Combine

iOSmacOStvOSwatchOSvisionOS

Combine is a declarative, reactive framework for processing values over time. You model asynchronous events as a Publisher that emits values to a Subscriber, then transform and compose those streams with operators in the Publishers namespace, scheduling work through types conforming to Scheduler. The framework provides concrete sources such as Just, Future, Deferred, Empty, and Fail, along with subjects like PassthroughSubject and CurrentValueSubject that you publish into imperatively, and ObservableObject with its ObservableObjectPublisher for emitting change notifications. Subscriptions are managed with Cancellable and AnyCancellable, so you can tear down a stream and stop receiving values when it is no longer needed.

Essentials 3

The core protocols that connect a source of values to a consumer over time.

  • Pr
    PublisheriOS 13.0+
    Declares that a type can transmit a sequence of values over time.
  • Pr
    SubscriberiOS 13.0+
    A protocol that declares a type that can receive input from a publisher.
  • Pr
    SubscriptioniOS 13.0+
    A protocol representing the connection of a subscriber to a publisher.

Operators 3

The namespaces that hold the operators used to transform, combine, and schedule streams.

  • En
    PublishersiOS 13.0+
    A namespace for types that serve as publishers.
  • En
    SubscribersiOS 13.0+
    A namespace for types that serve as subscribers.
  • En
    SubscriptionsiOS 13.0+
    A namespace for symbols related to subscriptions.

Publishing Values Imperatively 3

Subjects you publish into by hand to bridge imperative code with reactive streams.

  • Pr
    SubjectiOS 13.0+
    A publisher that exposes a method for outside callers to publish elements.
  • Cl
    PassthroughSubjectiOS 13.0+
    A subject that broadcasts elements to downstream subscribers.
  • Cl
    CurrentValueSubjectiOS 13.0+
    A subject that wraps a single value and publishes a new element whenever the value changes.

Concrete Publishers 6

Ready-made publishers that emit fixed, deferred, or recorded sequences of values.

  • St
    JustiOS 13.0+
    A publisher that emits an output to each subscriber just once, and then finishes.
  • Cl
    FutureiOS 13.0+
    A publisher that eventually produces a single value and then finishes or fails.
  • St
    DeferrediOS 13.0+
    A publisher that awaits subscription before running the supplied closure to create a publisher for the new subscriber.
  • St
    EmptyiOS 13.0+
    A publisher that never publishes any values, and optionally finishes immediately.
  • St
    FailiOS 13.0+
    A publisher that immediately terminates with the specified error.
  • St
    RecordiOS 13.0+
    A publisher that allows for recording a series of inputs and a completion, for later playback to each subscriber.

Connectable and Async Publishers 3

Publishers that defer connection or expose values through Swift concurrency.

  • Pr
    ConnectablePublisheriOS 13.0+
    A publisher that provides an explicit means of connecting and canceling publication.
  • St
    AsyncPublisheriOS 15.0+
    A publisher that exposes its elements as an asynchronous sequence.
  • St
    AsyncThrowingPublisheriOS 15.0+
    A publisher that exposes its elements as a throwing asynchronous sequence.

Observing Object Changes 2

Types that publish change notifications from an observable object.

  • Pr
    ObservableObjectiOS 13.0+
    A type of object with a publisher that emits before the object has changed.
  • Cl
    ObservableObjectPublisheriOS 13.0+
    A publisher that publishes changes from observable objects.

Managing Subscriptions 2

Types used to cancel a stream and stop receiving values when it is no longer needed.

  • Pr
    CancellableiOS 13.0+
    A protocol indicating that an activity or action supports cancellation.
  • Cl
    AnyCancellableiOS 13.0+
    A type-erasing cancellable object that executes a provided closure when canceled.

Scheduling Work 3

Protocols and schedulers that control when and where a publisher delivers values.

  • Pr
    ScheduleriOS 13.0+
    A protocol that defines when and how to execute a closure.
  • Pr
    SchedulerTimeIntervalConvertibleiOS 13.0+
    A protocol that provides a scheduler with an expression for relative time.
  • St
    ImmediateScheduleriOS 13.0+
    A scheduler for performing synchronous actions.

Encoding and Decoding 2

Protocols that abstract the top-level coders used by encoding and decoding operators.

  • Pr
    TopLevelEncoderiOS 13.0+
    A type that defines methods for encoding.
  • Pr
    TopLevelDecoderiOS 13.0+
    A type that defines methods for decoding.

Identifying Streams 2

Types that give subscribers and subscriptions a unique identity.

  • St
    CombineIdentifieriOS 13.0+
    A unique identifier for identifying publisher streams.
  • Pr
    CustomCombineIdentifierConvertibleiOS 13.0+
    A protocol for uniquely identifying publisher streams.

Structures 3

  • St
    AnyPublisheriOS 13.0+
    A publisher that performs type erasure by wrapping another publisher.
  • St
    AnySubscriberiOS 13.0+
    A type-erasing subscriber.
  • St
    PublishediOS 13.0+
    A type that publishes a property marked with an attribute.

Extends 3

OptionalResultSequence
← Foundation, System & Concurrency