Skip to content

Commit

Permalink
Don't use collectLatest() in UnidirectionalViewModel.observe()
Browse files Browse the repository at this point in the history
  • Loading branch information
cketti committed Oct 27, 2023
1 parent 054f95d commit 8ecf87d
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.runtime.State
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collectLatest

/**
* Interface for a unidirectional view model with side-effects ([EFFECT]). It has a [STATE] and can handle [EVENT]'s.
Expand Down Expand Up @@ -92,7 +91,7 @@ inline fun <reified STATE, EVENT, EFFECT> UnidirectionalViewModel<STATE, EVENT,
val dispatch: (EVENT) -> Unit = { event(it) }

LaunchedEffect(key1 = effect) {
effect.collectLatest {
effect.collect {
handleEffect(it)
}
}
Expand Down

0 comments on commit 8ecf87d

Please sign in to comment.