RxJava is a kind of must required skill for today’s mobile developers. It will be hard to go to the ground of RxJava. But after some plays, I will be much easy and you can use RxJava for your day today app development. It will increase your productivity and It will reduce the no of code you write dramatically.
What is RxJava
RxJava is a Java VM implementation of Reactive Extensions. Reactive Extension is an API for asynchronous programming with observable streams.
Why do we need to use RxJava
- Avoid complicated stateful programme, Use clean input and output functions over an observable stream.
- Reduce no of code lines.
- Proper error handling in the asynchronous environment.
- Abstract away low-level threading, synchronization and concurrency issues. So concurrency made easy.
Who are using RxJava
Most of the tech giant uses RxJava for their mobile app development. As example Airbnb, Trello, Netflix etc. Also, most of the sole developers and startups use RxJava to make their life easier.
Main component in RxJava
In the RxJava there are 2 main components.
- Observable – It emits the values. Represent the source of data. Observable will emit the data when the observer is listening. This data can be any number of data or zero. Based on the Observable the method which is executed in Observer will be different.
- Observer/Subscribers – it gets the values. Listen to the Observable.bservable.
Lets me explain these with a diagram.
In here you can see the observer subscribe to the Observable. Then Observable can emit data. When Observer emits data the relevant method in Observer will be executed.
Other than those two components the components there are other main components.
Subscription – The connection between Observable and Observer. There can be multiple Observer subscribe to the single Observable.
Operators – Operator will manipulate or filter the data which is emit by Observable before receiving to the observer.
Schedulers – Scheduler will define the thread which we need to use for Observable and Observer.
I think this enough for today. I will explain each of these components in a separate posts.
Happy Android 🤗