Last active
May 8, 2018 19:11
-
-
Save llinardos/be926a448e1e8cab229059adbf958080 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
class ThingsService { | |
func getThings(onCompletion callback: @escaping (Result<[Thing]>) -> Void) { | |
sendHttpRequestAsynchronously(url) { response in | |
DispatchQueue.main.async { | |
do { | |
let data = try getData(from: response) | |
let things = try doParsing(data) | |
callback(.success(things))) | |
} catch error { | |
callback(.failure(error)) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment