Simple Callback using RxJAVA

Sachin Kumar
2 min readDec 7, 2017

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:

  1. 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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Sachin Kumar
Sachin Kumar

Written by Sachin Kumar

Senior Java Backend Dev | Expertise in Java Microservices, Spring Boot Framework & Android apps development.

No responses yet

Write a response