- From: Kane York <notifications@github.com>
- Date: Sat, 05 Sep 2015 00:19:59 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/27/137924142@github.com>
I just ran into this. I'm trying to write a ServiceWorker that takes existing long-polling requests - possibly from multiple tabs - and multiplex all the tabs into a single long-polling request chain.
This fits extremely neatly into the "progressive enhancement" story of ServiceWorkers - if the worker is not installed, things will work normally, just with extra network traffic.
As ServiceWorkers do *not* have access to XMLHttpRequest, when a client subscribes to a new channel by abort()ing the previous request and starting a new one, the worker is forced to let the old (stale) fetch continue but ignore the result.
In the WIP code's architecture, it would be much more convenient to store a controller / context object like so:
```
function restartPolling() {
// ...
if (previousRequest) {
previousRequest.abort();
previousRequest = null;
}
// ...
fetch(...)
// ...
}
```
I hope that giving an actual use-case will help to make a decision.
---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/27#issuecomment-137924142
Received on Saturday, 5 September 2015 07:20:29 UTC