Created
July 12, 2016 19:09
-
-
Save mikekavouras/269c3a490b59cc6bbaf4b962bc56bb10 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
| struct User {} | |
| enum ResultType<T> {} | |
| enum Auth { | |
| case email(email: String, password: String) | |
| case facebook | |
| func login(completion: ResultType<User> -> Void) { | |
| switch self { | |
| case .email(let email, let password): | |
| EmailAuth.login(email, password: password, completion: completion) | |
| case .facebook: | |
| FacebookAuth.login(completion) | |
| } | |
| } | |
| func logout() { | |
| switch self { | |
| case .email: | |
| EmailAuth.logout() | |
| case .facebook: | |
| FacebookAuth.logout() | |
| } | |
| } | |
| } | |
| // MARK: Email | |
| private struct EmailAuth { | |
| static func login(email: String, password: String, completion: (ResultType<User>) -> Void) { | |
| } | |
| static func logout() { | |
| } | |
| } | |
| // MARK: Facebook | |
| private struct FacebookAuth { | |
| static func login(completion: (ResultType<User>) -> Void) { | |
| } | |
| static func logout() { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment