CancellationToken

public class CancellationToken : Cancellable

An object that allows to implement and control cancellation

  • block to call on cancellation

    Declaration

    Swift

    public typealias NotifyBlock = () -> Void
  • Returns state of the object

    Declaration

    Swift

    public var isCancelled: Bool { get }
  • Designated initializer

    Declaration

    Swift

    public init(isBackCancelAllowed: Bool = true)

    Parameters

    isBackCancelAllowed

    true if cancellation of cancellables after cancellation of the token is allowed. True by default

  • Adds block to notify when state changes to cancelled Specified block will never be called if the token will never be cancelled

    Declaration

    Swift

    public func notifyCancellation(_ block: @escaping NotifyBlock)
  • Automatically cancelles passed cancellable object on cancellation

    Declaration

    Swift

    public func add(cancellable: Cancellable)
  • Manually cancelles all attached items

    Declaration

    Swift

    public func cancel()