diff --git a/app/src/main/java/com/lighthouse/ui/MainViewModel.kt b/app/src/main/java/com/lighthouse/ui/MainViewModel.kt index 508b2dbf9..714a5014a 100644 --- a/app/src/main/java/com/lighthouse/ui/MainViewModel.kt +++ b/app/src/main/java/com/lighthouse/ui/MainViewModel.kt @@ -6,22 +6,21 @@ import com.lighthouse.domain.usecase.user.IsLoginUserUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import kotlinx.coroutines.launch +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import javax.inject.Inject @HiltViewModel internal class MainViewModel @Inject constructor( - private val isLoginUserUseCase: IsLoginUserUseCase + isLoginUserUseCase: IsLoginUserUseCase ) : ViewModel() { private val _isLoginFlow = MutableSharedFlow() val isLoginFlow = _isLoginFlow.asSharedFlow() init { - viewModelScope.launch { - isLoginUserUseCase().collect { isLogin -> - _isLoginFlow.emit(isLogin) - } - } + isLoginUserUseCase() + .onEach { _isLoginFlow.emit(it) } + .launchIn(viewModelScope) } }