Last active
February 29, 2020 16:54
-
-
Save lawloretienne/ce46823d89db3ea0afd7010deede66b5 to your computer and use it in GitHub Desktop.
EmailChangeObservable
This file contains hidden or 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 emailSubscription = | |
emailChangeObservable | |
.doOnNext(new Action1<CharSequence>() { | |
@Override | |
public void call(CharSequence charSequence) { | |
hideEmailError(); | |
} | |
}) | |
.debounce(400, TimeUnit.MILLISECONDS) | |
.filter(new Func1<CharSequence, Boolean>() { | |
@Override | |
public Boolean call(CharSequence charSequence) { | |
return !TextUtils.isEmpty(charSequence); | |
} | |
}) | |
.observeOn(AndroidSchedulers.mainThread()) // UI Thread | |
.subscribe(new Subscriber<CharSequence>() { | |
@Override | |
public void onCompleted() { | |
} | |
@Override | |
public void onError(Throwable e) { | |
e.printStackTrace(); | |
} | |
@Override | |
public void onNext(CharSequence charSequence) { | |
boolean isEmailValid = validateEmail(charSequence.toString()); | |
if (!isEmailValid) { | |
showEmailError(); | |
} else { | |
hideEmailError(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment