Skip to content

Instantly share code, notes, and snippets.

@dmytro-anokhin
Last active December 11, 2019 07:56
Show Gist options
  • Save dmytro-anokhin/7bfcc993819dffdeb5aec9fa39f4db2d to your computer and use it in GitHub Desktop.
Save dmytro-anokhin/7bfcc993819dffdeb5aec9fa39f4db2d to your computer and use it in GitHub Desktop.
import Foundation
class NetworkingA {
func loadJSON<T: Decodable>(withURL url: URL, type: T.Type = T.self, completion: @escaping (Result<T, Error>) -> Void) {
urlSession.dataTask(with: url) { data, response, error in
// ...
}.resume()
}
}
import Alamofire
class NetworkingB {
func load<T: Decodable>(_ url: URL, type: T.Type = T.self, completion: @escaping (Result<T, Error>) -> Void) {
AF.request(url).responseDecodable(of: type, queue: .main, decoder: JSONDecoder()) { response in
// ...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment