Add a cancel() method to Promise instances that allows consumers of Promise-based APIs to cancel execution of pending callbacks.
Cancellation is a specialized form of rejection, one which can be initiated from the Promise (consumer) rather than the Deferred (producer). If a Promise is still pending, calling its cancel() method triggers a rejection with a CancellationError that will propagate to any Promises originating from that Promise.
NOTE: Cancellation only propagates to Promises that branch from the target Promise. It does not traverse back up to parent branches, as this would poison the tree from which other Promises may have branched, causing unintended side-effects.
Add a
cancel()
method to Promise instances that allows consumers of Promise-based APIs to cancel execution of pending callbacks.Cancellation is a specialized form of rejection, one which can be initiated from the Promise (consumer) rather than the Deferred (producer). If a Promise is still pending, calling its cancel() method triggers a rejection with a CancellationError that will propagate to any Promises originating from that Promise.
NOTE: Cancellation only propagates to Promises that branch from the target Promise. It does not traverse back up to parent branches, as this would poison the tree from which other Promises may have branched, causing unintended side-effects.