A promise that is cancellable and also forces rejections to be errors. Can be used anywhere a normal promise can be
const promise = new Promise((resolve, reject, onCancel) => { const asyncOperation = new AsyncOperation(); onCancel(() => asyncOperation.cancelAndCleanup());
someLongAsyncOperation().then(resolve, reject); });
promise.cancel(); promise.cancelled(); // -> true promise.isCancelled(); // -> true `
`
A promise that is cancellable and also forces rejections to be errors. Can be used anywhere a normal promise can be
const promise = new Promise((resolve, reject, onCancel) => { const asyncOperation = new AsyncOperation(); onCancel(() => asyncOperation.cancelAndCleanup());
someLongAsyncOperation().then(resolve, reject); });
promise.cancel(); promise.cancelled(); // -> true promise.isCancelled(); // -> true
`