Mercurial > public > lazybear
comparison LazyBear/Views/Home/Networking/Home.swift @ 346:80bfa88c6b0f
Implementing Prop API
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 11 Apr 2021 19:55:47 +0200 |
parents | |
children | 280cbc5653b5 |
comparison
equal
deleted
inserted
replaced
345:fde2b30c719e | 346:80bfa88c6b0f |
---|---|
1 // | |
2 // Home.swift | |
3 // LazyBear | |
4 // | |
5 // Created by Dennis Concepción Martín on 11/4/21. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 class Home: ObservableObject { | |
11 @Published var showView = false | |
12 @Published var data = HomeResponse() | |
13 | |
14 func request(_ url: String) { | |
15 genericRequest(url: url, model: HomeResponse.self) { response in | |
16 // Is intradayPrices is empty -> request all data | |
17 if self.data.intradayPrices == nil { | |
18 self.data = response | |
19 } else { | |
20 // If not, request streaming data (without intradayPrices) | |
21 self.data.lists = response.lists | |
22 self.data.sectorPerformance = response.sectorPerformance | |
23 } | |
24 self.showView = true | |
25 } | |
26 } | |
27 } |