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
promise
for this CancellablePromiseDeclaration
Swift
public let promise: Promise<T>
-
Type of the delegate
thenable
Declaration
Swift
public typealias U = Promise<T>
-
Delegate
thenable
for this CancellablePromiseDeclaration
Swift
public var thenable: U { get }
-
Type of the delegate
catchable
Declaration
Swift
public typealias M = Promise<T>
-
Delegate
catchable
for 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
Thenable
conformance.See
Thenable.pipe
Declaration
Swift
public func pipe(to: @escaping (PromiseKit.Result<T>) -> Void)
-
See
Thenable.result
Declaration
Swift
public var result: PromiseKit.Result<T>? { 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
-
Initializes a new cancellable promise fulfilled with
Void
Declaration
Swift
public convenience init()
-
Initializes a new cancellable promise fulfilled with
Void
and with the givenCancellableTask
Declaration
Swift
public convenience init(task: CancellableTask)