Created
June 18, 2020 15:10
-
-
Save stevencurtis/b9292f371fb4e444f313dd04b50736ac to your computer and use it in GitHub Desktop.
NetworkManager
This file contains 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 | |
import Alamofire | |
protocol NetworkManagerProtocol { | |
func get(completionBlock: @escaping (AFDataResponse<Data>) -> Void) | |
} | |
class NetworkManager: NetworkManagerProtocol { | |
var session: Session? | |
var router: APIRouter? | |
required init(session: Session, router: APIRouter) { | |
self.session = session | |
self.router = router | |
} | |
func get(completionBlock: @escaping (AFDataResponse<Data>) -> Void) { | |
session?.request(router!).responseData(completionHandler: {data in | |
completionBlock(data) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment