Let’s take a typical case in our Android applications: searching for a user in our web service, based on a text entered by the user.

For that, we add a TextWatcher on our EditText, and so as soon as text changes, we call our web service so that it returns us the users whose name contains the entered text.

The render will be kind of slow since, for each letter removed/added, it makes a call to the web service.


Let’s add the RxBindings library to our build.gradle

Then use RxTextView.textChanges on our editText instead of addTextChangedListener

Limit network calls

We will use an Rx flow management operator to limit calls to our web service.
Here, the use of throttleWithTimeout will make sure to take into account only one change of text (more than three characters) every 5 seconds.

The interface will be more fluid, and it will limit the use of bandwidth (it’s better for the users who uses 3g).