NTP-2992 | Vedant Aggarwal | Onboarding activity relaunching on moving to background (#14825)
This commit is contained in:
@@ -20,7 +20,7 @@ import kotlinx.coroutines.withContext
|
||||
fun <T> ObserveAsEvents(flow: Flow<T>, key1: Any? = null, key2: Any? = null, onEvent: (T) -> Unit) {
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
LaunchedEffect(key1 = key1, key2 = key2, key3 = lifecycleOwner) {
|
||||
lifecycleOwner.repeatOnLifecycle(state = Lifecycle.State.STARTED) {
|
||||
lifecycleOwner.repeatOnLifecycle(state = Lifecycle.State.CREATED) {
|
||||
flow.collect { withContext(context = Dispatchers.Main.immediate) { onEvent(it) } }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user