Re: [whatwg/fetch] Aborting a fetch: The Next Generation (#447)

>From recent discussion & proposals, it looks like the controller and observer should be separate.

```js
const controller = new FetchController();

fetch(url, {
  controller,
  observer(observer) {
    // ...
  }
});
```

In this model, a single controller could be used by multiple fetches. A controller could observe an observer:

```js
controller.observe(observer);
```

…meaning it aborts & changes priority along with what it observes.

The observer would be exposed to the service worker:

```js
addEventListener('fetch', event => {
  const controller = new FetchController();
  controller.observe(event.fetchObserver);

  event.respondWith(
    fetch(url, {controller})
  );
});
```

-- 
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/447#issuecomment-273789078

Received on Thursday, 19 January 2017 14:25:51 UTC