package com.zaojiao.app.feat.home.plan

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.zaojiao.app.feat.design.UiState
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.stateIn

class HomePlanViewModel(

) : ViewModel() {
    val uiState: StateFlow<UiState<HomePlanState>> = flow<UiState<HomePlanState>> {
        delay(3000)
        emit(
            UiState.Success(
                HomePlanState(
                    todayPlanList = listOf(
                        "a", "b", "c"
                    )
                )
            )
        )
    }.stateIn(
        scope = viewModelScope,
        started = SharingStarted.WhileSubscribed(5_000),
        initialValue = UiState.Loading(),
    )
}