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

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

/**
 * FlashViewModel
 *
 * @author bai
 *
 * @param repo [FlashRepository]
 */
class FlashViewModel(private val repo: FlashRepository) : ViewModel() {

    /**
     * 获取当前登录用户
     */
    val getUser = repo.getUser()
        .stateIn(
            scope = viewModelScope,
            started = SharingStarted.WhileSubscribed(5000),
            initialValue = Data.loading()
        )
}