tc39 / proposal-observable

Observables for ECMAScript
https://tc39.github.io/proposal-observable/
3.06k stars 90 forks source link

pipe operator #192

Open c69 opened 6 years ago

c69 commented 6 years ago

Currently this proposal only defines the basic observable, but as you all probably know - nobody uses RxJS/etc for observables alone. The whole point is operators.

Standardizing operators is as a cimmon wisdom probably too early, but there is one operator worth incuding in base spec. That is pipe - the composition operator and preferred way to use operators in RxJS 5.5+

'pipe' allows to write operators as simple functions and thus extend the library.

This was already mentioned few times in other issues, so just wanted to highlight it separately.

benjamingr commented 6 years ago

Basically: The idea isn't to replace libraries like rx and xstream, the idea is for the native DOM and other platforms like Node to be able to expose observables which said libraries can consume.

Even if the DOM did ship observables - I'm not sure why we'd want to add pipe - IIUC it was added due to code splitting and DCE concerns which are not concerns the language itself has

c69 commented 6 years ago

to be able to expose observables which said libraries can consume

but what is the point of consuming Observable without operators ? 🤔

you need at least filter and map for even basic use cases, but as there are no operators included in this proposal at all - i was wondering how consumption will work ? with each library using their own implementation of from method ?

dmitry-korolev commented 6 years ago

Piping is essential, but it can be done with a vast set of tools, starting from const pipe = (...fns) => (val) => fns.reduce((p, f) => f(p), val) and ending with https://github.com/tc39/proposal-pipeline-operator.