Skip to content

Instantly share code, notes, and snippets.

@IronLeash
Last active June 5, 2020 14:26
Show Gist options
  • Save IronLeash/e133596641ad11d670836d29bea068b8 to your computer and use it in GitHub Desktop.
Save IronLeash/e133596641ad11d670836d29bea068b8 to your computer and use it in GitHub Desktop.
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