Mercurial > public > lazybear
view 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 source
// // Company.swift // LazyBear // // Created by Dennis Concepción Martín on 20/6/21. // import SwiftUI import Alamofire class Company: ObservableObject { @Published var showView = false @Published var showChart = true /// To show a ProgressView when the chart is refreshed (Date range selected) @Published var data = CompanyResponse() func request(_ url: String, _ requestType: RequestType) { if requestType == .refresh { self.showChart = false } 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 } } } }