Alternative way to achieve cancelable promise

Kagami Rosylight saschanaz at outlook.com
Mon May 8 06:05:29 UTC 2017


>So by default, promises must not be cancellable.

With some API change now the proposal allows this, similar to other token based proposals:

```
// if you don’t want to allow other consumers cancel this call
// for security reasons or whatever, you can disallow it by
// creating chain explicitly:
function foo() {
  const chain = new CancelableChain();

  // here myFetch() will register to cancellation chain and will be canceled
  // by chain.cancel()
  return myFetch(“url”, { chain });
}
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170508/3250f0c2/attachment.html>


More information about the es-discuss mailing list