kaushikgopal / RxJava-Android-Samples

Learning RxJava for Android by example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Port to RxJava 2.0

kaushikgopal opened this issue · comments

https://github.com/ReactiveX/RxJava/releases/tag/v2.0.0

Time and tide wait for no one. Should start porting these

How do you want to approach this? My suggestion would be to create a separate branch for rxjava 1.X and proceed with 2.X on master. I would be happy ot help out with the migration process as a rxjava learning exercise.
btw. I've just discovered your podcast. Love it!

You can have 1.x and 2.x in the same project, branching could make it harder to find examples for 1.x. Having both in the same branch also means you can have interop examples.

So what is the idea? Create alternative versions for each class, like TimeoutDemoFragment2 as a RxJava2 version of TimeoutDemoFragment? I'm not convinced if this is a right approach.
A link to the 1.X branch could be provided in the README so it should be easy enough to find.

I was thinking top level packages.

Ok, but how to present the examples app? Create a top level selection: rxjava / rxjava2?

I now understand where your coming from now. Shared source means we would also need to add a GUI switch. Keeping with having all source immediately visible. Yes a tabbed main page world work.

I do see why you would want a branch it.

Mostly to keep things separate. I'm also fine with one branch and top level packages. Ultimately @kaushikgopal should decide about the approach.

@qunerd : thanks for the kind words 🙏

@marukami + @qunerd: thanks for kickstarting this again.


So my original thought process was not to keep both 1.x and 2.x. Here's my reasoning:

  • simplicity.

To @qunerd's point, having two versions like TimeoutDemoFragment & TimeoutDemoFragment2 is a complete no no. that would be a maintenance nightmare. also there isn't a canonical reference to point 2.

also, it isn't simple to point someone to say "here's how you do X with RxJava". we would have to qualify it all saying ... actually, if you're doing RxJava 1.x then here's the one, alternatively 2.x....

nope, that sounds confusing.

  • new folks should be using 2.x now anyway

the original intent of this repository has always been to help folks get on board with RxJava. people starting off with Rx today, should be starting off with RxJava 2.0. so there's no reason for them to know how it's done with 1.x & 2.x (especially since there are fundamentally different api changes between the two)


☝️ all that being said. for us existing folks still using 1.x and who can't necessarily up and change to 2.x. it would be nice to have:

  1. a comparison of sorts (like 1.x vs 2.x)
  2. a migration path. for e.g. how does this same example that i know really well how to do in 1.x look in the world of 2.x.

I think both of the above though could just as easily be satisfied with the git history and a well organized migration PR.

we have quite a few examples at this point that demonstrate 1.x use, so people can always look up the version history for that example to see how it's done in 1.x (yes it's slightly more painful and less accessible but probably the price to pay for seeing the now non-standard way of doing things)

exposing the PR would clearly show the diffs between the old way and the new way, so i think that might be a better approach. I found this to be super useful for a Dagger 2 migration process. i looked up the repo and saw the PR that performed the migration and it was invaluable.


Ok, so how should we go about doing this. I'll open up a WIP PR and jot down all the examples that need to be ported. The problem with porting these example by example is that, for the interim time both 1.x and 2.x will have to co-exist. I think this is fine until we get the final PR merged. Given that RxJava has conveniently exposed them already in different packages. I think this should be fine. But we should eventually port them all, so there's no need for any 1.x references.

Let me know what you folks think. I'll start setting up the WIP PR meanwhile.

@kaushikgopal Sounds good. Totally agree!

Just to make sure. Migration to RxJava2 should be made by creating PRs to this branch: rxjava_2?

EDIT: I've started to look on the code and it seems that till RxBinding is not ported we can't do much progress as a lot of the Observables are creating from UI elements. We could use a converter library between RxJava and RxJava2 like RxJava2Interop till RxBinding is ported. What are your thoughts about it @kaushikgopal?

closing this issue. interested folks should watch #83

@marcinkunert : drats. you're right. hmm... ok moving this discussion to the PR