Descriptions can be added for groups with @groupDescription
, which will show up in
the index where groups are listed. This works for both manually created groups which
are created with @group
, and implicit groups like the Methods
group that this
description is attached to.
a normal promise or thenable
a function that cancels promise
. Calling cancel
after
promise
has resolved must be a no-op.
Protected
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
.
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
Analogous to Promise.catch
.
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 | () => voidThe 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.
Analogous 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
allStatic
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.
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.