Created
February 22, 2018 12:18
-
-
Save nic004/5e72116ab1b12abba585d5635ddb3161 to your computer and use it in GitHub Desktop.
promise with ReactiveSwift #4
This file contains 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
Promise<JSON, CommonError> { observer, disposable in | |
Alamofire.request("https://httpbin.org/get").responseJSON { response in | |
guard case let .success(value) = response.result else { | |
observer.send(error: .anyError) | |
return | |
} | |
observer.send(value: JSON(value)) | |
observer.sendCompleted() | |
} | |
}.value { json in | |
print(json) | |
}.completed { | |
print("done") | |
}.failed { error in | |
print("error") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment