view LazyBear/Views/Profile/Networking/Profile.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 6802c2393203
children 4c90e5b18632
line wrap: on
line source

//
//  Profile.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 16/4/21.
//

import SwiftUI

class Profile: ObservableObject {
    @Published var showView = false
    @Published var data = ProfileResponse()
    
    func request(_ url: String, isInitRequest: Bool) {
        genericRequest(url: url, model: ProfileResponse.self) { response in

            // If is the first request -> init()
            if isInitRequest {
                self.data = response
            } else {
                 // If not, request streaming data (without intradayPrices)
                self.data.quotes = response.quotes
            }

            self.showView = true
        }
    }
}