Skip to content

Instantly share code, notes, and snippets.

@llinardos
Last active May 8, 2018 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llinardos/be926a448e1e8cab229059adbf958080 to your computer and use it in GitHub Desktop.
Save llinardos/be926a448e1e8cab229059adbf958080 to your computer and use it in GitHub Desktop.
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