NTP-2992 | Vedant Aggarwal | Onboarding activity relaunching on moving to background (#14825)

This commit is contained in:
vedant aggarwal
2025-02-03 16:14:11 +05:30
committed by GitHub
parent 129765e0fd
commit d80e50d811

View File

@@ -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) } }
}
}