I have 3 EditText fields and I created 3 observables for these fields.
Observable<CharSequence> o1 = RxTextView.textChanges(field1); Observable<CharSequence> o2 = RxTextView.textChanges(field2); Observable<CharSequence> o3 = RxTextView.textChanges(field3);
I want to turn on the button when all three of these fields have some meaning. the user can enter values ββin any order in the fields. How can i do this?
EDIT
I used zip to achieve this.
Observable<CharSequence> o1 = RxTextView.textChanges(field1); Observable<CharSequence> o2 = RxTextView.textChanges(field2); Observable<CharSequence> o3 = RxTextView.textChanges(field3); Observable.zip(o1, o2, o3, (c1, c2, c3) -> c1.length() > 0 && c2.length() > 0 && c3.length() > 0).subscribe(myButton::setEnabled)
This case above works when I enter something into all three text fields. for example, I entered 1 character in all three text fields, then the button will be turned on. But when I delete a character in any of the three fields. zip will not be called since it will wait until the other 2 text fields pass some data before it calls onNext on the subscriber. so when I delete any character in any text field, I want my button to turn off again. How can i achieve this?
java android reactive-programming rx-java rx-android
g.revolution
source share