CancellablePromise
public class CancellablePromise<T> : CancellableThenable, CancellableCatchMixin
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
promisefor this CancellablePromiseDeclaration
Swift
public let promise: Promise<T> -
Type of the delegate
thenableDeclaration
Swift
public typealias U = Promise<T> -
Delegate
thenablefor this CancellablePromiseDeclaration
Swift
public var thenable: U { get } -
Type of the delegate
catchableDeclaration
Swift
public typealias M = Promise<T> -
Delegate
catchablefor this CancellablePromiseDeclaration
Swift
public var catchable: M { 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(task: CancellableTask? = nil, error: Error) -
Initialize a new cancellable promise bound to the provided
Thenable.Declaration
Swift
public convenience init<U: Thenable>(task: CancellableTask? = nil, _ bridge: U) where U.T == T -
Initialize a new cancellable promise that can be resolved with the provided
Resolver.Declaration
Swift
public convenience init(task: CancellableTask? = nil, resolver body: (Resolver<T>) throws -> Void) -
Initialize a new cancellable promise using the giving Promise and it’s Resolver.
Declaration
Swift
public convenience init(task: CancellableTask? = 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. -
Declaration
Swift
public class func valueCC(_ value: T) -> CancellablePromise<T>Return Value
a new fulfilled cancellable promise.
-
Internal function required for
Thenableconformance.See
Thenable.pipeDeclaration
Swift
public func pipe(to: @escaping (PromiseKit.Result<T>) -> Void) -
See
Thenable.resultDeclaration
Swift
public var result: PromiseKit.Result<T>? { get }Return Value
The current
Resultfor 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
-
Initializes a new cancellable promise fulfilled with
VoidDeclaration
Swift
public convenience init() -
Initializes a new cancellable promise fulfilled with
Voidand with the givenCancellableTaskDeclaration
Swift
public convenience init(task: CancellableTask)
View on GitHub
Install in Dash
CancellablePromise Class Reference