view LazyBear/Views/Home/Networking/Home.swift @ 390:6303385b3629

Companies added to watchlists now are correctly updated
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sun, 25 Apr 2021 19:52:04 +0200
parents 280cbc5653b5
children f843c6382529
line wrap: on
line source

//
//  Home.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 11/4/21.
//

import SwiftUI

class Home: ObservableObject {
    @Published var showView = false
    @Published var data = HomeResponse()
    
    func request(_ url: String, isInitRequest: Bool) {
        genericRequest(url: url, model: HomeResponse.self) { response in
            
            // If is the first request -> init()
            if isInitRequest {
                self.data = response
            } else {
                // If not, request streaming data (without intradayPrices and latestCurrencies)
                self.data.lists = response.lists
                self.data.sectorPerformance = response.sectorPerformance
            }
            self.showView = true
        }
    }
}