Mercurial > public > lazybear
diff LazyBear/Views/Company/Networking/Company.swift @ 450:4b8031e696e8
Change Bazooka to Alamofire
Alamofire is compatible with WatchOS and MacOS
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sat, 26 Jun 2021 16:36:53 +0200 |
parents | 01fa77358b82 |
children |
line wrap: on
line diff
--- a/LazyBear/Views/Company/Networking/Company.swift Wed Jun 23 13:03:00 2021 +0200 +++ b/LazyBear/Views/Company/Networking/Company.swift Sat Jun 26 16:36:53 2021 +0200 @@ -6,7 +6,7 @@ // import SwiftUI -import Bazooka +import Alamofire class Company: ObservableObject { @Published var showView = false @@ -15,19 +15,20 @@ func request(_ url: String, _ requestType: RequestType) { if requestType == .refresh { self.showChart = false } - let bazooka = Bazooka() - bazooka.request(url: url, model: CompanyResponse.self) { response in - switch requestType { - case .initial: - self.data = response - case .streaming: - self.data.quote = response.quote - case .refresh: - self.data.historicalPrices = response.historicalPrices + AF.request(url).responseDecodable(of: CompanyResponse.self) { response in + if let value = response.value { + switch requestType { + case .initial: + self.data = value + case .streaming: + self.data.quote = value.quote + case .refresh: + self.data.historicalPrices = value.historicalPrices + } + + self.showView = true + self.showChart = true } - - self.showView = true - self.showChart = true } } }