Last active
December 11, 2019 07:56
-
-
Save dmytro-anokhin/7bfcc993819dffdeb5aec9fa39f4db2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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