AnyCancelable

public class AnyCancelable : Cancelable
extension AnyCancelable: Hashable

A Cancellable object that automatically cancels on deinit.

Any resources referred by AnyCancelable will be released after cancellation.

This class has similar behavior to Combine.AnyCancellable, but doesn’t require iOS 13.

  • Creates AnyCancelable with the cancelling closure.

    Declaration

    Swift

    public init(_ closure: @escaping () -> Void)

    Parameters

    closure

    A closure that will be called when AnyCancellable is cancelled.

  • Creates AnyCancelable with the canceler object.

    Declaration

    Swift

    public convenience init<C>(_ canceler: C) where C : Cancelable

    Parameters

    closure

    The Cancelable token to be cancelled.

  • Creates AnyCancelable with the sequence of cancellables which will be canelled when AnyCancelable is cancelled.

    Declaration

    Swift

    public convenience init<S>(_ sequence: S) where S : Sequence, S.Element : Cancelable

    Parameters

    sequence

    Sequence of cancellables.

  • Cancels the activity.

    Declaration

    Swift

    public func cancel()
  • Stores cancellable object in set of Combine.AnyCancellable.

    Declaration

    Swift

    public func store(in set: inout Set<Combine.AnyCancellable>)
  • Stores cancellable object in collection of Combine.AnyCancellable.

    Declaration

    Swift

    public func store<C>(in collection: inout C) where C : RangeReplaceableCollection, C.Element == AnyCancellable
  • Hashes the essential components of this value by feeding them into the given hasher.

    Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • Returns a Boolean value that indicates whether two instances are equal, as determined by comparing whether their references point to the same instance.

    Declaration

    Swift

    public static func == (lhs: AnyCancelable, rhs: AnyCancelable) -> Bool
  • Stores cancellable object in a set.

    Declaration

    Swift

    public func store(in set: inout Set<AnyCancelable>)
  • Stores cancellable object in a collection.

    Declaration

    Swift

    public func store<C>(in collection: inout C) where C : RangeReplaceableCollection, C.Element == AnyCancelable