Advertisement
Guest User

Untitled

a guest
Sep 6th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class RegisterViewModel {
  2.    
  3.     var username: String? {
  4.         didSet {
  5.             emitValidity()
  6.         }
  7.     }
  8.    
  9.     var password: String? {
  10.         didSet {
  11.             emitValidity()
  12.         }
  13.     }
  14.    
  15.     fileprivate func emitValidity() {
  16.         let isValid = username?.isEmpty == false && password?.isEmpty == false
  17.         isValidListener?(isValid)
  18.     }
  19.    
  20.     // use a hook to check for form valid
  21.     var isValidListener: ((Bool) -> ())?
  22.    
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement