RxJava2 in Android Part1

RxJava is getting popular to used in the android application. Many of the developers they are supporting to use RxJava in building an android app. They are getting the good response to find that it taking the android app up to next level.

Rx java is using the Observer design pattern.I followed many article and tutorial for understanding what is observable and observer in technical term and every time got confused. Every article have different-2 explanation So I got more confused How to use RxJava, But most important when and Where to use.

Now Its create the confusion to you also right because to understand the technical thing required to understand first what is usage and existence in the real world.Yes sounds Great:).

So Let’s first take some real time example or daily basis usages to understand this technical concept.

Suppose Android point is the tutorial hub for android. Many lists of developers have subscribed for this tutorial. Once any new tutorial added into Android Point then listed subscribed developers will get notified for same that new article or tutorial added in Android point. So here developers are Observer And Android Tutorial point is Observable. So once Observable Object get updated then Observers will get notified.
Still confused. Let me give another example.

Everybody has its own permanent address and this address is registered on your passport and pan card etc. So once your Permanent address gets updated then your card authority get notify that something has changed in the permanent address. So here Your authority card are Observer and permanent address is the Observable. Once changes in Observable your observer get notify.

I hope now it’s clear about Observable and Observer in real time. Let’s check how is the same relation with technology term.Any Object has its own property and behaviors. The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state (means the change in his property or behavior ), all of its dependents are notified and updated automatically.Again confusion Ohh !! Let’s connect above example with Java Program.

I hope this is understandable. Now let's focus How Observable and Observer following this pattern.Observable is the class and Observer is the interface. Observable maintain the list of Observers. When Observable Object gets changes then its notify to all Observers to get the update. Again Confused Oh No!!!. Let me again explained by example.

This all about the Observable pattern.Now Rx is following this pattern and used this in android development. I heard that now many android developers are using this pattern and it gives the good result.

It avoids boilerplate code I mean it avoids the unnecessary duplicate code. Many of the library that implemented on this pattern. For example, Retrofit is using RX Pattern and Realm also using this concept and many more good available library that working with Rx Team. I will explain in detail related Rx(Reactive Programming) Java2 to use in Android application development. Here are the details of my next tutorial link Rxjava2 in android part2.Thanks for reading this post.