import { CancellablePromise } from "https://deno.land/x/grm@0.8.0/deps.ts";
A promise with a cancel
method.
If canceled, the CancellablePromise
will reject with a [[Cancellation
]]
object.
Constructors
Properties
As 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.
Methods
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.
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.
Static Methods
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Analogous to Promise.all
.
Creates a CancellablePromise
that is resolved with an array of results
when all of the provided Promises
resolve or reject.
Creates a CancellablePromise
that is resolved with an array of results
when all of the provided Promise
s resolve or reject.
Creates a CancellablePromise
that is resolved or rejected when any of
the provided Promises
are resolved or rejected.
Analogous to Promise.reject
.
Like CancellablePromise.resolve
, canceling the returned
CancellablePromise
is a no-op.
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.