RxJava is another library that’s been cropping up all over the place in the AndroidDev world. Similar to my experience with Dagger, RxJava was (and still does feel like) a sizable mountain to climb. With the help of some posts, I feel like I’ve finally been able to overcome at least a good majority of the steep learning curve. I’ll be the first to admit I still have a lot to learn.

JavaRx: Observable Stream Sequence Provider…whaaaat?

Cracking open RxJava without the right resources is really difficult because of the following:

RxJava is more a programming paradigm than library (Functional Reactive Programming)

RxJava doesn’t really have a specific use case. It can solve a lot of problems in various ways.

RxJava’s naming conventions don’t seem that natural to me and thus it’s hard to read, especially when you don’t have lambdas/closures. I’m looking at you Android… no Java 8. No, I don’t have any better naming suggestions :D

It’s also hard not to feel dumb and close the browser tab when you read this in the RxJava Intro section in the Wiki:

RxJava is a Java VM implementation of Reactive Extensions: a library for composing asynchronous and event-based programs by using observable sequences.

Again, maybe you’re smarter than me.

What worked for me

The first thing I recommend reading is a general intro to what RxJava is all about: Functional Reactive Programming. I’d recommend reading through An intro to Functional Reactive Programming, but don’t get too bogged down in details. It can get dense quickly and thus discouraging. You just want to get a high level understanding of what FRP is about.

Next, I’d highly recommend this 4 part series by a guy named Dan Lew. RxJava finally clicked when I read these, and I’m grateful he took the time to write the posts! They’re short, digestible, and have solid content. He also gives examples with and without closures/lambdas… a small but very helpful thing.

Next, I’d suggest reading an article that gives advice to devs just starting out with RxJava (in a mobile context). The tl;dr is “don’t use it everywhere right away. Use it for something small like network requests.”

RxMarbles is a great interactive site which helped/helps me visualize different aspects of RxJava (you can click and drag the marbles… I missed that the first time around :D). It’s linked in the offical RxJava wiki, so you know it’s good!

Lastly, the main documentation is always helpful :)

Bonus: Retrofit + RxJava

For those of you using Square’s Retrofit library for API calls - which I’d highly recommend if you’re looking for a networking library - they actually already support returning Observables right out of the box with something like the following:

@GET("/user/{id}/profile") Observable<Profile> getUserProfile(@Path("id") int id);

How about that!

[EDIT] Jake Wharton gave a quick 5-minute talk at Netflix recently about composing API calls using Retrofit and RxJava. See below for slides and video

Final Thoughts

While I haven’t played around much with RxJava, I’m excited to see the instances where this can be used to cleverly solve a problem. I’d love to hear the ways which you’ve found it to be useful in your development process if you’re a regular RxJava user… though my guess is you’re probably not if you’re reading this post.

Hope these resources help you in your journey to broadening your horizons and ultimately making you a better Android developer. As always, should you have any other suggested resources you think I should include, feel free to comment below!