CC-Archived / promise-as3

Promises/A+ compliant implementation in ActionScript 3.0
167 stars 52 forks source link

Implement support for Promise cancellation. #24

Closed johnyanarella closed 10 years ago

johnyanarella commented 10 years ago

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.