RxAndroid third-party libraries

The boom of reactive programming has taken the Android world. The popularity grows daily, so, there are a lot libraries you should consider when you immerse yourself in this world.

RxBinding

RxJava binding APIs for Android UI widgets from the platform and support libraries (rxbinding-appcompat-v7, rxbinding-design, rxbinding-recyclerview-v7 and rxbinding-support-v4).

Handle Button click event:

Subscription buttonSub = RxView.clicks(button).subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
//handle on click here
}
});

Handle EditText click event:

Subscription editTextSub = RxTextView.textChanges(editText).subscribe(new Action1<CharSequence>() {
@Override
public void call(CharSequence value) {
// do some work with new text
}
});

RxLifecycle

Lifecycle handling APIs for Android apps using RxJava. Allows for automatic completion of sequences based on Activity or Fragment lifecycle events.

RxPermissions

This library allows the usage of RxJava with the new Android M permission model. Prevents you to split your code between the permission request and the result handling. Avoids you have to request the permission in one place and handle the result in Activity.onRequestPermissionsResult().

Request the CAMERA permission:

RxPermissions rxPermissions = new RxPermissions(this);
rxPermissions
.request(Manifest.permission.CAMERA)
.subscribe(granted -> {
if (granted) { // Always true pre-M
// I can control the camera now
} else {
// Oups permission denied
}
});

Android-ReactiveLocation

Library that wraps location play services API boilerplate with a reactive friendly API.

What can you do with that?

  • easily connect to Play Services API
  • obtain last known location
  • subscribe for location updates
  • use location settings API
  • manage geofences
  • geocode location to list of addresses
  • activity recognition
  • use current place API
  • fetch place autocomplete suggestions

RxLocation (RxJava 2)

This library wraps the Location APIs in RxJava 2 Observables, Singles, Maybes and Completables. No more managing GoogleApiClients! Also, the resolution of the location settings check is optionally handled by the lib.

RxClipboard

RxJava binding APIs for Android Clipboard. You can observe 6 different types of clipboard changes:

  • Plain text
  • Html
  • Plain text OR Html
  • Uri
  • Intent
  • ClipData (raw)

RxAndroidBle

Reactive library for handling Bluetooth LE devices. The library does for you:

  • Fancy asynchronous operations support (read, write, notifications)
  • Threading management in order to meet Android contracts
  • Connection and operation error handling

RxSensor

A lightweight wrapper around SensorManager which introduces reactive stream semantics to Sensor and Trigger data.

SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

RxSensorManager rxSensorManager = new RxSensorManager(sensorManager);
Observable<SensorEvent> sensorObservable =
rxSensorManager.observeSensor(Sensor.TYPE_ACCELEROMETER, SensorManager.SENSOR_DELAY_NORMAL);
sensorObservable.subscribe(new Action1<SensorEvent>() {
@Override public void call(SensorEvent event) {
// TODO react to event...
}
});

RxAnimation

This is Animation wrapping Observable. You can get event Observable. And you can call animation chain more simple.