comparison LazyBear/Views/Company/Networking/Company.swift @ 399:5c99883c7964

Implementing networking in CompanyView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 15 May 2021 12:31:40 +0200
parents
children f843c6382529
comparison
equal deleted inserted replaced
398:933546fa5651 399:5c99883c7964
1 //
2 // Company.swift
3 // LazyBear
4 //
5 // Created by Dennis Concepción Martín on 15/5/21.
6 //
7
8 import SwiftUI
9
10 class Company: ObservableObject {
11 @Published var showChartView = false
12 @Published var chartData = ChartResponse()
13
14 func request(_ url: String, isInitRequest: Bool, _ view: String) {
15 if view == "chart" {
16 genericRequest(url: url, model: ChartResponse.self) { response in
17 if isInitRequest { self.chartData = response } // If is the first request -> init()
18 else { self.chartData.quote = response.quote } // If not, request streaming data (without intradayPrices)
19 self.showChartView = true
20 }
21 }
22 }
23 }