Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

RunKit + npm: folktale

node v8.17.0
version: master
endpointsharetweet
var { task } = require("folktale@2.2.0-alpha1/concurrency/task") const taskA = task((resolver) => { console.log("executing task A"); resolver.onCancelled(() => { console.log("taskA cancelled"); }); setTimeout(() => { console.log("taskA complete"); if (!resolver.isCancelled) { resolver.resolve("taskA"); } }, 100); }) const taskB = task((resolver) => { console.log("executing task B"); resolver.onCancelled(() => { console.log("taskB cancelled"); }); setTimeout(() => { console.log("taskB complete"); if (!resolver.isCancelled) { resolver.resolve("taskB"); } }, 200); }) const taskC = task((resolver) => { console.log("executing task C"); resolver.onCancelled(() => { console.log("taskC cancelled"); }); setTimeout(() => { console.log("taskC complete"); if (!resolver.isCancelled) { resolver.resolve("taskC"); } }, 300); }) const exec = taskA.chain(() => taskB).chain(() => taskC).run(); setTimeout(() => { console.log("Cancelling task"); exec.cancel(); }, 150); exec.listen({ onCancelled: () => console.log("desired: cancelled task"), onResolved: () => console.log("should not happen: resolved task"), onRejected: () => console.log("should not happen: rejected task") });
Created from: https://npm.runkit.com/folktale
Loading…

no comments

    sign in to comment