Last active
June 5, 2020 14:26
-
-
Save IronLeash/e133596641ad11d670836d29bea068b8 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
protocol AuthenticationManagerDelegate: class { | |
func userDidLogout() | |
func userDidLogin(_ user: User) | |
} | |
@objc class AuthenticationManager: NSObject { | |
static let sharedInstace = AuthenticationManager() | |
public var user: User? | |
public var multicastDelegate = MulticastDelegate<AuthenticationManagerDelegate>() | |
func logout()->() { | |
self.multicastDelegate.invoke({ $0.userDidLogout() }) | |
} | |
func login(email: String, password: String, completionHandler: @escaping (LoginResponseResult)->())->() { | |
/*Network request to get user object with email and password*/ | |
self.user = user | |
multicastDelegate.invoke({ $0.userDidLogin(user)}) | |
completionHandler(.success(user)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment