package jp.co.progress_llc.portal.feature.depart.presentation import javax.inject.Inject import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import jp.co.progress_llc.portal.feature.depart.repository.DepartRepositoryImpl import jp.co.progress_llc.portal.core.data.Route @HiltViewModel class DepartViewModel @Inject constructor( private val departRepositoryImpl: DepartRepositoryImpl ) : ViewModel(), DepartUiLogic { private val _routes = MutableStateFlow>(emptyList()) override val routes: StateFlow> = _routes.asStateFlow() init { loadRoutes() } private fun loadRoutes() { viewModelScope.launch { try { val routeList = departRepositoryImpl.getAllRoute() _routes.value = routeList } catch (e: Exception) { _routes.value = emptyList() } } } }