Last active
August 20, 2019 13:53
-
-
Save saru2020/deff28a3be889d2c43989e1bef42b84d to your computer and use it in GitHub Desktop.
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
//1 | |
struct LoginViewModel { | |
// 2 | |
let email = BehaviorRelay<String>(value: "") | |
// 3 | |
let password = BehaviorRelay<String>(value: "") | |
// 4 | |
let isValid: Observable<Bool> | |
init() { | |
// 5 | |
isValid = Observable.combineLatest(self.email.asObservable(), self.password.asObservable()) | |
{ (email, password) in | |
// 6 | |
return email.isValidEmail() | |
&& password.isValidPassword() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment