RxBinding
RxBinding is a set of libraries that allow you to react to user interface events via the RxJava paradigm. Let’s take a look at a few examples.
Button click event:
Button b = (Button)findViewById(R.id.button);
Subscription buttonSub =
RxView.clicks(b).subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
// do some work here
}
});
// make sure to unsubscribe the subscription
Text change listener for an EditText:
final EditText name = (EditText) v.findViewById(R.id.name);
Subscription editTextSub =
RxTextView.textChanges(name)
.subscribe(new Action1<String>() {
@Override
public void call(String value) {
// do some work with the updated text
}
});
// Make sure to unsubscribe the subscription