Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save archieedwards/1af8042e428cbc25fdaed35e23a30b12 to your computer and use it in GitHub Desktop.
Save archieedwards/1af8042e428cbc25fdaed35e23a30b12 to your computer and use it in GitHub Desktop.
protocol NetworkClientProtocol {
func executeRequest(request: URLRequest, completion: @escaping (Data?, Error?) -> Void)
}
extension URLSession: NetworkClientProtocol{
/// this is where the real request happens
func executeRequest(request: URLRequest, completion: @escaping (Data?, Error?) -> Void) {
let task = dataTask(with: request) { (data, _, error) in
completion(data, error)
}
task.resume()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment