Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save archieedwards/a2cc58ab754f4cdf9d4b5c188264300c to your computer and use it in GitHub Desktop.
Save archieedwards/a2cc58ab754f4cdf9d4b5c188264300c 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