News for hackers. Stuff that matters.
Re:Cancelable Promises: Why was this proposal withdrawn? by spion on Monday December 19, 2016 @10:15AM (#13211871)
If there was a specialized Observable that is guaranteed to only generate one value per subscription, and the API indicated this clearly by naming such an observable "Task" or "Future", I'd be all for it.

Otherwise, its like using Arrays or Lists instead of Maybe. Hope that clears up why its "bizarre", but if not, its because the contract is not restrictive enough.

Example: `let x:Observable<Row[]>`. Does this generate a single event with all the rows? Or does it do row batching? No idea. Can I consume both the same? Not really, depends on the use. e.g. if I want to sort the items, I'd have to implement merge sort for the second case.

Re:Cancelable Promises: Why was this proposal withdrawn? by staltz on Monday December 19, 2016 @09:03PM (#13216787)
> If there was a specialized Observable that is guaranteed to only generate one value per subscription, and the API indicated this clearly by naming such an observable "Task" or "Future", I'd be all for it.

Given any Observable `obs`, you can consume it with `obs.take(1).subscribe()` instead of `obs.subscribe()` and then you'll be sure it only generates one value per subscription.

But in practice the generation of multiple values in itself is rarely an issue to worry about. Often you just want to drop consecutive duplicates, there's an operator for that: `distinctUntilChanged`. You can also end an observable based on a timeout.

Multiple values emitted is a pseudo-problem, and often your programming becomes more powerful ("does more in less lines of code") by using that capability.

Re:Cancelable Promises: Why was this proposal withdrawn? by spion on Tuesday December 20, 2016 @05:39AM (#13218782)
Okay. Please replace all Maybe instances in your code with Arrays and let me know how that goes.
Re:Cancelable Promises: Why was this proposal withdrawn? by int_19h on Monday December 19, 2016 @06:51PM (#13216093)
I think the argument here was indeed to treat promises as a subset of observables, not replace them with observables. Just as option type is a subset of collections that can have at most 1 element (but all operations that apply to any other collection, like say "map", still make sense for it).