
Simple Callback using RxJAVA
In this article we are going to implement the sample app having one textview indicating counter which gets incremented on click of a simple button “INCREMENT”.

We are explaining the complete implementation of RxJAVA via following steps:
- In build.gradle at Module level, add the following dependencies:

2. In MainActivity.java in onCreate() we are initialising the Observer which is responsible for listening to the event which is emitted by Observable :

3. We have onClick Listener for the “INCREMENT” button declared in xml file, method name is increaseValue() to increment the counter in TextView, in this method we are sending an event using just operator of class Observable and it returns the Observable type. Note : to send this event we need to subscribe Observer to Observable.

4. Now, after clicking on “INCREMENT” button we can clearly see the counter is getting incremented because we have Observer subscribed to listen to the events in this case onNext() of the Observer gets called.

For more better clarity take a clone from Git : https://github.com/sachin1kumar/SimpleRxJAVA.git