Last active
January 30, 2019 15:31
-
-
Save dimebt/4874f2a0a95fb1bbd53351f14be5ce43 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
func promiseFetchUserData(user: [String: Any]) -> Promise<User> { | |
return Promise<User> { seal in | |
fetchUserData(for: user, completion: { (response, results, error) in | |
switch response { | |
case .success: | |
seal.fulfill(results) | |
case .fail: | |
seal.reject(error) | |
} | |
}) | |
} | |
} | |
func promiseLoginUser(user: User) -> Promise<Bool> { | |
return Promise<Bool> { seal in | |
loginUser(user: user, completion: { (response, resolts, error) in | |
switch response { | |
case .success: | |
seal.fulfill(true) | |
case .fail: | |
seal.reject(error) | |
} | |
}) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment