Working easy-cancelable-promise examples running in your browser: work that stops when it is canceled, progress reported through the promise, and a group canceled with one call.Examples
Learn by doing
Less reading.
More understanding.
Three small applications running the real library.
Run them, stop them, and take the pattern back to yours.
Promise17 stepsRan after Stop
CancelablePromise0 stepsRan after Stop
Cancellation
01Stop waiting, and stop the work too
The same task runs in a native Promise and in a CancelablePromise. Press Stop and count the steps each one still runs.
Open examplepromise.onProgress(…)62%
25 updates received
Progress
02Know how far the work is, without a second channel
The same task in a native Promise and in a CancelablePromise. One is silent until the end, the other reports every step through the promise itself.
Open example6 tasksmaxConcurrent: 2
task 1done
task 3canceled
task 5never started
Groups
03Six tasks, one cancel
Six tasks, two at a time, in a queue written with native promises and in groupAsCancelablePromise. Press Stop and see which tasks still start.
Open exampleLearn the model behind the examples.
A short path from a Promise to a promise you can cancel.