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

Sorry for jumping back into the discussion so much later. 

> What we're talking about here is a way to let an observer signal disinterest in the result, and let a promise react to all observers becoming disinterested.

This is exactly why I think it should be called an `IgnorablePromise` and should have an `ignore` method, rather than an `abort` or `cancel` method. Note that I'm interested in this on a general level, not just for `fetch` but for other promise methods too. As long as you want to chain the promises together there is no way to guarantee that the initial action will be aborted. Instead of suggesting (through the name of the method) that all started actions will be aborted, I believe that `ignore` should be used to indicate that the result will not be needed. If the code (through refcounting) can realize that some work is not needed and can indeed be aborted, then that's an added bonus. But the user of the API shouldn't call the `cancel`/`abort` method expecting the work to be cancelled, since there is no way to guarantee that. 

If you have a promise that you need to give to multiple consumers, then you should clone it, just like you have to clone the request/response of fetch. That can easily be done like so:

```js
let parent = fetch(url);
let child1 = parent.then(r => r);
let child2 = parent.then(r => r);
child1.ignore()//child2 will still resolve
```

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

Received on Saturday, 28 March 2015 13:08:42 UTC