Let’s learn RxJava for Android
So there is a new kid on the block. It is called RxJava and I got some questions about it on a job interview. I looked at some lessons about it on Egghead.IO but I have never used it. So I want to share with you some projects and lessons I have watched that helped me understand it better.
- RxJava in 15 Minutes – THIS video gives you a brief overview of what is the idea behind RxJava. A must watch!
- A video by one of the creators of RxJava – THIS is great!!! It explains why it was created, sample usages and the main idea. After this video you will surely get what is the idea behind RxJava.
- RetroFit & RxJava – so, let’s see how we can use it with some popular networking libraries. And HERE is a video from Jake Wharton about how to use it with RetroFit. Do you get the sense now how you can use it?
- Let’s see some sample usages. How about using it with volley, making requests which need more time and making a sample event bus. Check the examples HERE.
- There are some mystic things happening here. So the things come from Microsoft, let’s read the website and book they have for Reactive Extensions in .NET. It is great!
- Some good blog posts about how to use RxJava in Android – Post1, How To Use RxJava, RxJava vs AsyncTasks
- A great tutorial from Grokking Android about RxJava Part 1, Part 2, Part 3, Part 4
- A list of all available operators – HERE
- Implementing your own operators post
- What is Backpressure and how to handle the problem if two Observables are trying to be zipped and one is emitting items faster than the other – LINK
- Try an implementation with MVP, Dagger 2 and RxJava from HERE
In a short summary – RxJava is about making all the asynchronous calls easier and allows you to join multiple different requests together avoiding the callback hell. The concept looks great and it will surely ease your life. Make sure to try it out whenever you can.
You should visit the first few links, watch and read them. Afterwards you need to start experimenting. A TED talk said that 20 hours are enough to learn anything. Spend your 20 hours and you will have a great understanding of RxJava.
Edit 03.03.2015: I have been using it now for few days. It is awesome. I used the zip method for combining multiple queries and get the result as one. Also creating observables is very easy. You can use create, defer, just and many other methods. This is definitely a must to implement in Android. An also the combination with RetroLambda is great. You can use lambda expressions which will simplify your code a lot.