package com.ys.bdtp.adm.mvvm.vm.cad

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.ys.bdtp.adm.mvvm.model.Data
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.stateIn

class CadViewModel(private val repo: CadRepository) : ViewModel() {

    /**
     * 建筑楼层一对多 Flow
     */


    fun getProjectWithBuildingAndFloors(id: String) = repo.getProjectWithBuildingAndFloors(id)
        .stateIn(
            scope = viewModelScope,
            started = SharingStarted.WhileSubscribed(5000),
            initialValue = Data.loading()
        )

    fun getFloorWithCads(id: String) = repo.getFloorWithCads(id)
        .stateIn(
            scope = viewModelScope,
            started = SharingStarted.WhileSubscribed(5000),
            initialValue = Data.loading()
        )

}
