Using RxBinding

RxAndroid does not have any tools to create Observables off Android events, but there are many libraries that provide means to do this. The most popular library is RxBinding, which allows you to create Observables off of UI widgets and events.

There are many factories available in RxBinding. One static factory class you may use frequently is RxView, which allows you to create Observables off controls that extend View and broadcast different events as emissions. For instance, change your activity_main.xmlto have a Button and TextView class, as follows:

 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout     xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" ...

Get Learning RxJava now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.