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: 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.
Readonly
cancelCancel the CancellablePromise
.
Optional
reason: stringAnalogous 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.
Optional
onFulfilled: null | ((value) => TResult1 | PromiseLike<TResult1>)Optional
onRejected: null | ((reason) => TResult2 | PromiseLike<TResult2>)a new CancellablePromise
Analogous to Promise.catch
.
Optional
onRejected: null | ((reason) => 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.
Optional
onFinally: null | (() => void)The callback to execute when the Promise is settled (fulfilled or rejected).
A Promise for the completion of the callback.
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.
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
allAnalogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Analogous to Promise.all
.
an array that may contain CancellablePromise
s, promises,
thenables, and resolved values
a CancellablePromise
, which, if canceled, will cancel each
of the promises passed in to CancellablePromise.all
.
Static
allCreates a CancellablePromise
that is resolved with an array of results
when all of the provided Promises
resolve or reject.
An array of Promises
.
A new CancellablePromise
.
Creates a CancellablePromise
that is resolved with an array of results
when all of the provided Promise
s resolve or reject.
An array of Promise
s.
A new CancellablePromise
. Canceling it cancels all of the input
promises.
Static
raceCreates a CancellablePromise
that is resolved or rejected when any of
the provided Promises
are resolved or rejected.
An array of Promises
.
A new CancellablePromise
. Canceling it cancels all of the input
promises.
Static
delaya CancellablePromise
that resolves after ms
milliseconds.
Generated using TypeDoc
This example shows off how TypeDoc handles
A promise with a
cancel
method. If canceled, theCancellablePromise
will reject with aCancellation
object. Originally from real-cancellable-promise.