//
//  YHHomeViewCoontroller.swift
//  galaxy
//
//  Created by davidhuangA on 2024/1/3.
//  Copyright © 2024 www.davidhuang.com. All rights reserved.
//

import Foundation
import RxSwift

class YHHomeViewController: YHBaseViewController {
    //C 对应的 VM
    let disposeBag = DisposeBag()

    lazy var homeReqVM : YHHomePageViewModel = {
        return YHHomePageViewModel()
    }()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //1.UI
        initView()
        
        //2.网络请求
        bind()
        requestData()
        
    }
    
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        //for test hjl
        requestData()
        
    }
    
    private func requestData() {
        self.homeReqVM.getHomeConfig()
    }
    
    private func bind() {
        homeReqVM.subject.subscribe(onNext: { model in
            print("网络请求获取的数据是====>")
            print(model)
            
        }).disposed(by: disposeBag)
    }
    
    private func initView()->Void {
        navigationItem.title = "首页"
        view.backgroundColor =  UIColor(hex:0xE9E9E9)
    }
    
}
