Re: [fetch] Aborting a fetch (#27)

@eplawless 

> I appreciate the correction, the important distinction then is multicast (like Promise) vs unicast (like Task or Stream). 

I don't believe so, RxJS has multicast semantics too for when you want to share that value, when you do that you _almost always_ use refcount semantics for the cancellation - so much that `.publish().refCount()` is so common that there are [utility methods](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/share.md) basically so you don't have to type it.

The only way to deal with multiple subscribers _deterministically_ (without reliance on GC) in a sound way for explicit cancellation is to ref-count the number of subscribers - just like Rx does.

The main advantage of a task is that it would not be shared by default and it can for example avoid caching the value. It also means that it would have simpler cancellation but that a task can no longer be cancelled if/when converting it to a promise. A task would also presumably have to `throw` on a second subscriber. 

That said, again, we have sound promise cancellation today - so while tasks are a very interesting concept to explore given the current state of `fetch` it sounds like a much easier path and one users will find a lot simpler. 

Tasks and promises have _strict_ semantics where _creating the task launches the operation_ since they are proxies for values and not actions. Observables have ultra-strict semantics but _only after you subscribed to them_. To clarify - an observable is like a function, a promise is like a function's return value - you compose and combine promises through composing and combining regular functions. You compose and combine observables through lifted operators.

> This is likely a nitpick but for the example @appden gave, based on the Promises/A+ spec, there will absolutely be a second Promise created if retreiveResult returns a value, will there not?

Petka already answered that, but feel free to look at the jsfiddle examples I posted in my above comment that show that this is a non-issue.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/27#issuecomment-177272637

Received on Saturday, 30 January 2016 18:47:06 UTC