Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistency with RxJS (and interop) #45

Open
jayphelps opened this issue Aug 16, 2019 · 6 comments
Open

Consistency with RxJS (and interop) #45

jayphelps opened this issue Aug 16, 2019 · 6 comments
Labels

Comments

@jayphelps
Copy link

jayphelps commented Aug 16, 2019

What are your thoughts on Flowable's API compared to the latest RxJS? (v6 as of this writing, v4 API used to be very similar to Flowable)

The biggest differences off hand:

  • RxJS uses pipeable operators e.g. source.pipe(take(1)) instead of prototype methods like Flowable (and old versions of RxJS). See here why.
  • RxJS uses next() error() complete() instead of onNext() onError() onComplete(). This was changed a while ago because Observable was (technically still is) being proposed as an addition to the TC39 ECMAScript standard and that's what they wanted. Even though the standard is effectively dead at the moment, the rename ship has long since sailed. RxJS also supports a shorthand overload .subscribe(nextFn, errorFn, completeFn) passing them as arguments instead of passing an object with those names--Flowable supports just .subscribe(nextFn) overload.

Biggest reason I'm bringing up is I would imagine a dev using Flowable would also use RxJS, and having things consistent makes for a better DX.

Having a toObservable() method would also be handy for cases where you don't want to handle backpressure, but alternatively (or in addition) RxJS could support consuming Flowable via import { from } from 'rxjs'; from(flowable).subscribe(...)

I imagine this has been discussed internally, but couldn't find anything publicly.

@jayphelps jayphelps changed the title Interop with RxJS Consistency with RxJS (and interop) Aug 16, 2019
@jayphelps
Copy link
Author

More cruising led me to find that Netifi's JS lib adds toObservable interop: https://github.com/netifi/netifi-js-client/blob/3ec310824f643d61a8a6386458ff95524f3373a8/src/rx/FlowableAdapter.js#L35-L47

@josephsavona
Copy link
Contributor

I’m no longer actively involved in development of this library but aligning w the RxJS api makes sense. When we first wrote the Flowable library, RxJS and the Observable spec proposal was still in flux and it wasn’t clear whether to go w the onNext() or next() style naming. ”pipeable” operators also seem fine, they certainly solve some issues and my only concern is that it would introduce a bit of perf overhead.

The main thing to figure out is if a migration plan is possible or necessary.

@OlegDokuka
Copy link
Member

@jayphelps I'm working right now on reactive-streams-js. Once it is done I'm planning to get rid of Flowable/Single since they are handmade. Since RS Spec is the standard - interop is guaranteed by the set of rules so interop with others RS spec based libs will be implicit. E.g it will be easy to use Reactor-JS or have an adapter to RxJS world

@JWood48
Copy link

JWood48 commented Nov 20, 2020

is there any progress on this issue?

@OlegDokuka
Copy link
Member

I started the work in that direction and have already created the first bits -> #104. The next PR will be on the integration with Observable

@viglucci
Copy link
Member

viglucci commented Mar 6, 2022

It's been awhile since this issue was opened, so some things have developed. I suspect that moving forward, the RxJS interop conversation will happen in relation to #158. We've already implemented an initial "adapter" that provides interop via the below:

I'll wait to close or progress this issue further until we have a published 1.0.0-alpha version where the adapter can be exercised by consumers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants