Learn reactive programming with RxJava and RxAndroid. If you want a job as an android developer, you need to know this stuff.
What is Reactive programming?
The concept of reactive programming is centered around the idea of observable objects.
So the first question is... What exactly is an observable object?
Simply put, an observable object is an object that can be observed by something else. Such that if the properties of that object change, the observers of that object will be notified. This is the same idea as with LiveData and the MVVM architecture.
- LiveData is the observable
- And you can have any number of observers observing it.
Now you might be thinking:
"If you can create observable objects using LiveData, and LiveData is what Google recommends using in their best-practices guide, why should you use RxJava & RxAndroid?"
And I want to say on record:
Many of the things RxJava and RxAndroid are used for can be more easily done with LiveData and proper architecture like MVVM. However, there's still enough other benefits that it's well worth knowing about. Not to mention every Android job you apply for will expect RxJava knowledge. But they might not expect you to know about LiveData and MVVM. So a safe bet is to learn RxJava.
Why you should Learn RxJava & RxAndroid
In my opinion, with respect to Android development, the real payoff of using RxJava & RxAndroid is two fold:
It has powerful operators that make creating observable objects very simple.
You can create observables out of lists, arrays, custom data objects, combine multiple observables into one... You can sort, filter, find max and mins.. The list goes on.
You can very easily pass data back and forth between threads.
- Running tasks on a background thread
- Retrieving results on the main thread
- Or visa versa. It doesn't matter. It makes threading incredibly simple. RxJava and RxAndroid is the death of AsyncTask. You'll never use it again.
I'm sure you noticed that I didn't mention observers or being able to subscribe to observers and react to changes in the "Why you should Learn RxJava & RxAndroid" section above. That's because (in my opinion), LiveData and the MVVM architecture does this better.
- It's easier
- You can do the same thing with less code (most of the time)
- And it leads to a much cleaner code structure (my favorite reason)
So, yes - RxJava gives you the ability to create observable objects and react to changes to those objects. But I think LiveData is superior in that regard.
But once again, RxJava and RxAndroid is still very worth knowing about! It has very powerful operators and threading functionality.
# lectures: 22
Total video time: 02:30:72