Echo JS 0.11.0

<~>
MaxArt 2656 days ago. link parent 1 point
It's not like one excludes the other, as they have different purposes. Promises are good for one-time events, while observables are meant for streams of events. It becomes problematic when we try to bend one to do the job of the other.

For example, right now we have a nice `fetch` API that *seems* to be perfect for promises (we've been using them since jQuery implemented `done` and `fail`), but now we've not only lost the ability to cancel a request, but also to watch for the progress in uploading the request and downloading the response.

You wouldn't use a Promise to listen to a click event, either.

Conversely, using observables for simple tasks (for example, getting a Blob out of a <canvas>) introduces unnecessary syntactic clutter.

The problem now is that we have native Promises, but still no native Observables.

Replies

lordgreg 2655 days ago. link 1 point
Um... that Promises too advanced are could I understand for complex things that would in all cases be complex and overdeveloped.

However, not even once in my last Year of trying to get into RxJS aka Observables wasn't I amazed in any way. Not only amazed but stressed about the docs and examples. 

I would NEVER, use Observables over Promises in any of my current apps. Reading "Angular 2 is terrible" makes a perfect example about the whole "Observables" pattern usage. 

I would, however, completely agree with you- I would NEVER use Observables for a simple tasks. But until today, noone gave me any special PROs about Observables because of which I would switch immediately to RxJS. 

Angular team (Google) is forcing Observables pattern into JS world. Is this really really needed?

People aka. us, developers, always forgot to keep it simple. Do not overdevelop, as Angular did.
MaxArt 2655 days ago. link 1 point
Well, as I said, you don't have to *switch* - you can use them both, like you can do in Angular 2.

The odd thing is that we've been using "observables" since, like, forever. Of course not of the kind we have in RxJS, but we have events (the "observables") and listeners (the "subscribers"), and we lacked all the semantic syntax ofr transformation and manipulation such as map, forEach and so on. So, theoretically, it *shouldn't* be that hard to grok Observables.

But it kind of is, because of the mentioned sematic syntax which could be quite jarring from the usual procedural style.

But yes, Observables are somewhat needed. Maybe not in this form, but the concept behind them is necessary because, as I said, not everything could be achieved with a Promise.
lordgreg 2651 days ago. link 1 point
Thank you for your reply. Appreciate it.

And that is also the point, Observables are the "next big thing", however... no one can't explain what would we use them for.

:)