Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@saru2020
Last active August 20, 2019 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saru2020/deff28a3be889d2c43989e1bef42b84d to your computer and use it in GitHub Desktop.
Save saru2020/deff28a3be889d2c43989e1bef42b84d to your computer and use it in GitHub Desktop.
//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