diff --git a/app/src/main/java/com/debk007/template/presentation/viewmodel/HomeViewModel.kt b/app/src/main/java/com/debk007/template/presentation/viewmodel/HomeViewModel.kt index 4b2a562..20f7797 100644 --- a/app/src/main/java/com/debk007/template/presentation/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/com/debk007/template/presentation/viewmodel/HomeViewModel.kt @@ -1,8 +1,5 @@ package com.debk007.template.presentation.viewmodel -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.State -import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.debk007.template.model.ProductDetailsDto @@ -10,6 +7,8 @@ import com.debk007.template.repository.Repository import com.debk007.template.util.ApiState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import javax.inject.Inject @@ -19,9 +18,9 @@ class HomeViewModel @Inject constructor( ) : ViewModel() { // TODO: Set UI State - private val _productDetailsState: MutableState> = - mutableStateOf(ApiState.Loading) - val productDetailsState: State> get() = _productDetailsState + private val _productDetailsState: MutableStateFlow> = + MutableStateFlow(ApiState.Loading) + val productDetailsState = _productDetailsState.asStateFlow() init { getProductDetails()