Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JohnSundell/63b1e4d23be82f088647f85ac93bb170 to your computer and use it in GitHub Desktop.
Save JohnSundell/63b1e4d23be82f088647f85ac93bb170 to your computer and use it in GitHub Desktop.
protocol NetworkEngine {
typealias Handler = (Data?, URLResponse?, Error?) -> Void
func performRequest(for url: URL, completionHandler: @escaping Handler)
}
extension URLSession: NetworkEngine {
typealias Handler = NetworkEngine.Handler
func performRequest(for url: URL, completionHandler: @escaping Handler) {
let task = dataTask(with: url, completionHandler: completionHandler)
task.resume()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment