Re: [whatwg/fetch] Fetch termination API "meeting" (#455)

# Summary

## Decided

**We're looking for something that cancels the request, but also the response if it's in-flight**. This means aborting the body stream if the response body is in-flight.

**We're dismissing 'tokens' as an API**. Although they work well for cancellation, they don't work well for other modifiers like "priority change".

**Adding methods to the return value of `fetch()` feels too risky**. The API gets pretty confusing. The 'species' could be a regular promise:

```js
let fetchling = fetch(url);
// Works…
fetchling.cancel();
fetchling = fetch(url).then(r => r.json());
// Does not work, "cancel" is undefined.
fetchling.cancel();
```

Although this provides an easy way to return a regular promise, it's pretty confusing. If `.then` created a controllable fetch promise:

```js
let fetchling = fetch(url).then(r => r.json());
// Works as expected:
fetchling.cancel();

fetchling = fetch(url).then(() => fetch(anotherURL));
// Only cancels the first fetch, which is weird:
fetchling.cancel();

const fetches = Promise.all([
  fetch(url1),
  fetch(url2),
  fetch(url3)
]);
// Does not work, "cancel" is undefined
fetches.cancel();
```

**We're going to move forward with the revealing-function pattern**.

```js
fetch(url, {
});
``` 

what happens when cancel
service worker can only observe
abort returns promise
observable addeventlistener

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/455#issuecomment-274869169

Received on Tuesday, 24 January 2017 17:08:06 UTC