Class

AnyCancellable

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

Declaration

final class AnyCancellable

Overview

Subscriber implementations can use this type to provide a “cancellation token” that makes it possible for a caller to cancel a publisher, but not to use the Subscription object to request items.

An AnyCancellable instance automatically calls cancel() when deinitialized.

Topics

Creating a Type-Erased Cancellable

init(() -> Void)

Initializes the cancellable object with the given cancel-time closure.

Canceling Actions

Storing AnyCancellable Instances

func store<C>(in: inout C)

Stores this type-erasing cancellable instance in the specified collection.

func store(in: inout Set<AnyCancellable>)

Stores this type-erasing cancellable instance in the specified set.

Initializers

Instance Properties

Relationships

Conforms To

See Also

Publishers

protocol Publisher

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

enum Publishers

A namespace for types that serve as publishers.

struct AnyPublisher

A type-erasing publisher.

protocol ConnectablePublisher

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

struct Published

A type that publishes a property marked with an attribute.

protocol Cancellable

A protocol indicating that an activity or action supports cancellation.