Skip to content

Commit

Permalink
Added clear cache on flow completion
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEblan committed Sep 20, 2024
1 parent 01112de commit 6a7f2f0
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.eblan.socialworkreviewer.framework.countdowntimer.CountDownTimerWrapp
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
Expand All @@ -62,7 +63,7 @@ class QuestionViewModel @Inject constructor(
private val _questionUiState = MutableStateFlow<QuestionUiState?>(null)
val questionUiState = _questionUiState.onStart {
getCategory()
}.stateIn(
}.onCompletion { clearCache() }.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = null,
Expand Down

0 comments on commit 6a7f2f0

Please sign in to comment.