what the CancellablePromise
resolves to
a normal promise or thenable
a function that cancels promise
. Calling cancel
after
promise
has resolved must be a no-op.
Optional
reason: stringReadonly
cancelCancel the CancellablePromise
.
Optional
reason: stringProtected
Readonly
promiseAs a consumer of the library, you shouldn't ever need to access
CancellablePromise.promise
directly.
If you are subclassing CancellablePromise
for some reason, you
can access this property.
This is necessary to make CancellablePromise
assignable to Promise
.
Analogous to Promise.catch
.
Optional
onRejected: null | ((reason: any) => TResult | PromiseLike<TResult>)Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
A Promise for the completion of the callback.
Optional
onFinally: null | (() => void)The callback to execute when the Promise is settled (fulfilled or rejected).
Analogous to Promise.then
.
onFulfilled
on onRejected
can return a value, a normal promise, or a
CancellablePromise
. So you can make a chain a CancellablePromise
s
like this:
const overallPromise = cancellableAsyncFunction1()
.then(cancellableAsyncFunction2)
.then(cancellableAsyncFunction3)
.then(cancellableAsyncFunction4)
Then if you call overallPromise.cancel
, cancel
is called on all
CancellablePromise
s in the chain! In practice, this means that
whichever async operation is in progress will be canceled.
a new CancellablePromise
Optional
onFulfilled: null | ((value: T) => TResult1 | PromiseLike<TResult1>)Optional
onRejected: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)Static
allAnalogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Analogous to Promise.all
.
a [[CancellablePromise
]], which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
Static
allCreates a CancellablePromise
that is resolved with an array of results
when all of the provided Promises
resolve or reject.
A new CancellablePromise
.
An array of Promises
.
Creates a CancellablePromise
that is resolved with an array of results
when all of the provided Promise
s resolve or reject.
A new CancellablePromise
. Canceling it cancels all of the input
promises.
An array of Promise
s.
Static
delaya CancellablePromise
that resolves after ms
milliseconds.
Static
raceCreates a CancellablePromise
that is resolved or rejected when any of
the provided Promises
are resolved or rejected.
A new CancellablePromise
. Canceling it cancels all of the input
promises.
An array of Promises
.
Static
rejectAnalogous to Promise.reject
.
Like CancellablePromise.resolve
, canceling the returned
CancellablePromise
is a no-op.
Optional
reason: unknownthis should probably be an Error
object
Static
resolveAnalogous to Promise.resolve
.
The returned promise should resolve even if it is canceled. The idea is that the promise is resolved instantaneously, so by the time the promise is canceled, it has already resolved.
Generated using TypeDoc
A promise with a
cancel
method.If canceled, the
CancellablePromise
will reject with a [[Cancellation
]] object.