comparison LazyBear/Views/Company/Networking/Company.swift @ 401:f843c6382529

Add Enumeration to Networks files
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Thu, 20 May 2021 21:04:49 +0200
parents 5c99883c7964
children 8357b101df67
comparison
equal deleted inserted replaced
400:6055a867d2b6 401:f843c6382529
9 9
10 class Company: ObservableObject { 10 class Company: ObservableObject {
11 @Published var showChartView = false 11 @Published var showChartView = false
12 @Published var chartData = ChartResponse() 12 @Published var chartData = ChartResponse()
13 13
14 func request(_ url: String, isInitRequest: Bool, _ view: String) { 14 func request(_ url: String, _ requestType: RequestType, _ view: String) {
15 if view == "chart" { 15 if view == "chart" {
16 genericRequest(url: url, model: ChartResponse.self) { response in 16 genericRequest(url: url, model: ChartResponse.self) { response in
17 if isInitRequest { self.chartData = response } // If is the first request -> init() 17 switch requestType {
18 else { self.chartData.quote = response.quote } // If not, request streaming data (without intradayPrices) 18 case .initial:
19 self.chartData = response
20 case .refresh:
21 print("refresh")
22 case .streaming:
23 self.chartData.quote = response.quote
24 }
25
19 self.showChartView = true 26 self.showChartView = true
20 } 27 }
21 } 28 }
22 } 29 }
23 } 30 }