Skip to content

Instantly share code, notes, and snippets.

@nic004
Created February 22, 2018 12:18
Show Gist options
  • Save nic004/5e72116ab1b12abba585d5635ddb3161 to your computer and use it in GitHub Desktop.
Save nic004/5e72116ab1b12abba585d5635ddb3161 to your computer and use it in GitHub Desktop.
promise with ReactiveSwift #4
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