toObservable(phone);
Observable<Boolean> emailValid, phoneValid;
emailValid = emailObservable.map(
email -> FormUtils.checkEmail(email)
);
phoneValid = phoneObservable.map(
phone -> FormUtils.checkPhone(phone)
);
emailError = toField(emailValid.map(
emailValid -> emailValid ? null : "Invalid Email";
);
phoneError = toField(phoneValid.map(
phoneValid -> phoneValid ? null : "Invalid Phone";
);
loginEnabled = toField(Observable.combineLatest(emailValid, phoneValid,
(emailValid, phoneValid) -> emailValid && phoneValid
));
} LoginState() {
Observable<String> emailObservable = toObservable(email);
Observable<String> phoneObservable = toObservable(phone);
Observable<Boolean> emailValid, phoneValid;
emailValid = emailObservable.map(
email -> FormUtils.checkEmail(email)
);
phoneValid = phoneObservable.map(
phone -> FormUtils.checkPhone(phone)
);
emailError = toField(emailValid.map(
emailValid -> emailValid ? null : "Invalid Email";
);
phoneError = toField(phoneValid.map(
phoneValid -> phoneValid ? null : "Invalid Phone";
);
loginEnabled = toField(Observable.combineLatest(emailValid, phoneValid,
(emailValid, phoneValid) -> emailValid && phoneValid
));
}