- From: Jake Archibald <notifications@github.com>
- Date: Thu, 26 Feb 2015 03:23:15 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
Received on Thursday, 26 February 2015 11:23:42 UTC
I like @tabatkins' ref-count idea. Although I'd only count child abortable promises as refs, `Promise.resolve(fetchp)` would be a simple observer. So ``` var rootFetchP = fetch(url).then(r => r.json()); var childFetchP1 = rootFetchP.then(data => fetch(data[0])); var childFetchP2 = rootFetchP.then(data => fetch(data[1])); var childP = Promise.resolve(rootFetchP).then(r => r.text()); childFetchP1.abort(); // …aborts fetch(data[0]), or waits until it hits that point in the chain, then aborts. // fetch(url) continues childFetchP2.abort(); // …aborts fetch(data[1]), or waits until it hits that point in the chain, then aborts. // fetch(url) aborts also, if not already complete. Out of refs. // childP rejects (or hangs) as a result ``` --- Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/625#issuecomment-76162225
Received on Thursday, 26 February 2015 11:23:42 UTC