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


protocol ConnectablePublisher


Use a ConnectablePublisher when you need to perform additional configuration or setup prior to producing any elements.

This publisher doesn’t produce any elements until you call its connect() method.

Use makeConnectable() to create a ConnectablePublisher from any publisher whose failure type is Never.


Performing Explicit Connections

func connect() -> Cancellable

Connects to the publisher, allowing it to produce elements, and returns an instance with which to cancel publishing.


Connecting Automatically

func autoconnect() -> Publishers.Autoconnect<Self>

Automates the process of connecting or disconnecting from this connectable publisher.

See Also

Connectable Publishers

Controlling Publishing with Connectable Publishers

Coordinate when publishers start sending elements to subscribers.