Re: [fetch] Aborting a fetch (#27)

P.S. once again, [previous snippet playground is here](https://gist.github.com/WebReflection/0ca8fac8013f76fb4d06) the main difference, in terms of behavior, is that whenever you `.then(...)` or `.catch(...)` a cancel-able Promise, it MUST create a Promise that is able to cancel its parent. This preserves Promise chain-ability, propagating the cancel-able intent down the road.

```js
// simulating my second proposal manually
var cancel, cancelable = new Promise(function (res, rej) {
  // le async resolution
  var interval = setTimeout(res, 1000, 'OK');
  cancel = function (why) {
    clearTimeout(interval);
    rej(why);
  };
});
// making it cancel-able out there ... 
cancelable.cancel = cancel;


// now the regular user-land behavior

cancelable.then(...).then(...).then(...) // and eventually .cancel();
// even at the end of that chain
```

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/27#issuecomment-87884170

Received on Tuesday, 31 March 2015 00:25:06 UTC