import { CancellablePromise } from "https://deno.land/x/grm@0.8.0/deps.ts";
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.
Returns
a new CancellablePromise