Created
February 29, 2020 17:34
-
-
Save lawloretienne/2e3bd3a78aa6b07fd54b808df0b65d9d to your computer and use it in GitHub Desktop.
SignInFieldsSubscription
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subscription signInFieldsSubscription = | |
Observable.combineLatest(emailChangeObservable, passwordChangeObservable, | |
new Func2<CharSequence, CharSequence, Boolean>() { | |
@Override | |
public Boolean call(CharSequence email, CharSequence password) { | |
boolean isEmailValid = validateEmail(email.toString()); | |
boolean isPasswordValid = validatePassword(password.toString()); | |
return isEmailValid && isPasswordValid; | |
} | |
}).observeOn(AndroidSchedulers.mainThread()) // UI Thread | |
.subscribe(new Observer<Boolean>() { | |
@Override | |
public void onCompleted() { | |
} | |
@Override | |
public void onError(Throwable e) { | |
e.printStackTrace(); | |
} | |
@Override | |
public void onNext(Boolean validFields) { | |
if (validFields) { | |
enableSignIn(); | |
} else { | |
disableSignIn(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment