Skip to content

Instantly share code, notes, and snippets.

@mikekavouras
Created July 12, 2016 19:09
Show Gist options
  • Select an option

  • Save mikekavouras/269c3a490b59cc6bbaf4b962bc56bb10 to your computer and use it in GitHub Desktop.

Select an option

Save mikekavouras/269c3a490b59cc6bbaf4b962bc56bb10 to your computer and use it in GitHub Desktop.
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