Protocol

Subject

A publisher that exposes a method for outside callers to publish elements.

Declaration

protocol Subject : AnyObject, Publisher

Overview

A subject is a publisher that you can use to ”inject” values into a stream, by calling its send() method. This can be useful for adapting existing imperative code to the Combine model.

Topics

Delivering Elements to Subscribers

func send(Self.Output)

Sends a value to the subscriber.

Required.

func send()

Sends a void value to the subscriber.

Delivering Life Cycle Events to Subscribers

func send(subscription: Subscription)

Sends a subscription to the subscriber.

Required.

func send(completion: Subscribers.Completion<Self.Failure>)

Sends a completion signal to the subscriber.

Required.

Relationships

Inherits From

See Also

Subjects

class CurrentValueSubject

A subject that wraps a single value and publishes a new element whenever the value changes.

Beta
class PassthroughSubject

A subject that broadcasts elements to downstream subscribers.

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