tc39 / proposal-observable

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

Is it possible to use ES7 Observable now? #139

Closed xareelee closed 7 years ago

xareelee commented 7 years ago

Can I use ES7 Observable through some tools like babel or npm now? If true, how to get started?

Could you put some info or the links about the state of this proposal in the README.md (e.g. approved or not)?

ljharb commented 7 years ago

ES7 is ES2016, and it was finalized last June. Observables are not in it (nor in ES2017, which is nearly finalized).

Proposals have 4 stages, and you can read all about them as well as see the status of this one on the official proposals repo.

Since it's API and not syntax, there wouldn't be a babel transform, it'd have to be a polyfill/shim on npm.

appsforartists commented 7 years ago

@xareelee, there are many Observable libraries for JavaScript:

One of those ought to meet your needs. There's nothing to transform, so you don't need Babel. The DOM APIs are independent of the Observable ones, so I don't think any existing library is going to get you the element.on('pointermove').forEach() syntax you see in the README.

xareelee commented 7 years ago

@ljharb, thank you for pointing out the current state and the resource links.

@appsforartists, I've already used RxJS 5, but it is slightly slower (about 20-30%) than ECMAScript Promise for one async value. Most importantly, it has the memory footprint issue with the garbage collection when running benchmark (heap out of memory). I'm seeking a faster one, so I found this proposal.

appsforartists commented 7 years ago

@xareelee There are so many Observable implementations; have you tried most.js?

xareelee commented 7 years ago

@appsforartists, Yes, I'm currently trying most.js, but it lacks many useful methods and flow-types.

appsforartists commented 7 years ago

@xareelee Be the PR you wish to see in the world:

https://flowtype.org/docs/third-party.html#writing-custom-library-definition-files

benjamingr commented 7 years ago

@xareelee first of all, you can use observables alongside promises (I do), you can mix and match them.

Second of all - is 20% difference really important for your workflow?

benlesh commented 7 years ago

I've already used RxJS 5, but it is slightly slower (about 20-30%) than ECMAScript Promise for one async value. Most importantly, it has the memory footprint issue with the garbage collection when running benchmark (heap out of memory). I'm seeking a faster one, so I found this proposal.

@xareelee what benchmark? I'd like to fix this.

xareelee commented 7 years ago

@blesh I rewrite the graphql()/execute() part of graphql-js with RxJS to replace the Promise-based implementation to support reactive programming. The refactoring has not been published yet.

If you are still interested, I'd like to share the commit of the benchmark.

marcusradell commented 7 years ago

Note that them most.js code is split into smaller modules. You might need to use more than the core one. I use most-subject and some lib for holding a value (shareReplay(1)).

Both RxJS and Most.js have great gitter channels.