CancellablePromise

public class CancellablePromise<T> : CancellableThenable, CancellableCatchMixin
extension CancellablePromise: _PMKSharedWrappers
extension CancellablePromise: _PMKCatchWrappers
extension CancellablePromise: _PMKSharedVoidWrappers where C.T == Void

A CancellablePromise is a functional abstraction around a failable and cancellable asynchronous operation.

At runtime the promise can become a member of a chain of promises, where the cancelContext is used to track and cancel (if desired) all promises in this chain.

  • Delegate promise for this CancellablePromise

    Declaration

    Swift

    public let promise: Promise<T>
  • U

    Type of the delegate thenable

    Declaration

    Swift

    public typealias U = Promise<T>
  • Delegate thenable for this CancellablePromise

    Declaration

    Swift

    public var thenable: U { get }
  • C

    Type of the delegate catchable

    Declaration

    Swift

    public typealias C = Promise<T>
  • Delegate catchable for this CancellablePromise

    Declaration

    Swift

    public var catchable: C { get }
  • The CancelContext associated with this CancellablePromise

    Declaration

    Swift

    public var cancelContext: CancelContext
  • Tracks the cancel items for this CancellablePromise. These items are removed from the associated CancelContext when the promise resolves.

    Declaration

    Swift

    public var cancelItemList: CancelItemList
  • Initialize a new rejected cancellable promise.

    Declaration

    Swift

    public convenience init(cancellable: Cancellable? = nil, error: Error)
  • Initialize a new cancellable promise bound to the provided Thenable.

    Declaration

    Swift

    public convenience init<U>(_ bridge: U, cancelContext: CancelContext? = nil) where T == U.T, U : Thenable
  • Initialize a new cancellable promise that can be resolved with the provided Resolver.

    Declaration

    Swift

    public convenience init(cancellable: Cancellable? = nil, resolver body: (Resolver<T>) throws -> Void)
  • Initialize a new cancellable promise using the given Promise and its Resolver.

    Declaration

    Swift

    public convenience init(cancellable: Cancellable? = nil, promise: Promise<T>, resolver: Resolver<T>)
  • Declaration

    Swift

    public class func pending() -> (promise: CancellablePromise<T>, resolver: Resolver<T>)

    Return Value

    a tuple of a new cancellable pending promise and its Resolver.

  • Internal function required for Thenable conformance.

    See

    Thenable.pipe

    Declaration

    Swift

    public func pipe(to: @escaping (Result<T, Error>) -> Void)
  • Declaration

    Swift

    public var result: Result<T, Error>? { get }

    Return Value

    The current Result for this cancellable promise.

  • Blocks this thread, so—you know—don’t call this on a serial thread that any part of your chain may use. Like the main thread for example.

    Declaration

    Swift

    public func wait() throws -> T
  • T

    Undocumented

    Declaration

    Swift

    public typealias T = T
  • Undocumented

    Declaration

    Swift

    public typealias BaseOfT = CancellablePromise<T>

Available where T == Void

  • Initializes a new cancellable promise fulfilled with Void

    Declaration

    Swift

    public convenience init()
  • Initializes a new cancellable promise fulfilled with Void and with the given Cancellable

    Declaration

    Swift

    public convenience init(cancellable: Cancellable)