Re: [ServiceWorker] Returning a FetchPromise from fetch() (#625)

The other way to do it that doesn't break perfectly normal behavior is to have `.then()` still return a `FetchPromise` (abortable), but you can call `.then()` multiple times and it ref-counts - if all of its chains abort, it aborts as well.

Then you can cast to a plain Promise with `Promise.resolve(fetchp)`, like normal.  (Or, since that'll leak a ref, maybe we do add an explicit `.promise()` or something to it that returns a plain promise that just observes the value.  That makes it easy to prevent leaking a ref to libraries that'll chain off of the value without returning the chained object, too.)

Really, the reason I strongly disagree here is that observing the value multiple times *is not a problem*.  That's totally fine; the problem is that always returning a `FetchPromise` when you chain leaks the abort capability as well.  You're solving the capabiliity-leak by removing the ability to observe multiple values, which is pretty scorched-earth.  There are more delicate ways to solve this that have similar usability.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/625#issuecomment-75345558

Received on Saturday, 21 February 2015 00:46:01 UTC