Skip to content
Roger Hu edited this page Nov 25, 2015 · 91 revisions

Overview

RxJava is a library built for Java that is used to help write in a style known as [reactive programming] (https://gist.github.com/staltz/868e7e9bc2a7b8c1f754#what-is-reactive-programming). Reactive programming often requires a significant mindset shift from traditional models because it means thinking of everything as an asynchronous data stream. Not only are mouse clicks asynchronous data streams, but also network calls, database fetches, or cache retrievals could be considered as well.

Imagine trying to perform a series of chained tasks using AsyncTask. We could implement the dispatching on the onPostExecute() of each task, but writing code to dispatch certain tasks depending on certain states will end up cause endless complicated code. Reactive programming helps provide an abstraction layer that describes how these events should be sequenced.

Reactive programming also provides an abstraction layer to combine, create, or filter them in a way that is easier to understand and maintain for the developer.

Setup

Setup your app/build.gradle:

dependencies {
  compile 'io.reactivex:rxjava:1.0.16'
  compile 'io.reactivex:rxandroid:1.0.1'
}

References

Finding these guides helpful?

We need help from the broader community to improve these guides, add new topics and keep the topics up-to-date. See our contribution guidelines here and our topic issues list for great ways to help out.

Check these same guides through our standalone viewer for a better browsing experience and an improved search. Follow us on twitter @codepath for access to more useful Android development resources.

Clone this wiki locally