Closed sbernikov closed 11 months ago
Description I have bottomSheet destination in my project and appropriate composable function that displays its content. Inside this function I listen to lifecycle events via DisposableEffect:
@Composable fun ObserveLifecycleEvents( lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, onStart: (() -> Unit)? = null, onResume: (() -> Unit)? = null, onPause: (() -> Unit)? = null, onStop: (() -> Unit)? = null, ) { DisposableEffect(lifecycleOwner) { val observer = LifecycleEventObserver { _, event -> when (event) { Lifecycle.Event.ON_START -> onStart?.invoke() Lifecycle.Event.ON_RESUME -> onResume?.invoke() Lifecycle.Event.ON_PAUSE -> onPause?.invoke() Lifecycle.Event.ON_STOP -> onStop?.invoke() else -> {} } } lifecycleOwner.lifecycle.addObserver(observer) onDispose { lifecycleOwner.lifecycle.removeObserver(observer) } } }
But onResume/onPause events are not received if I move app to background, for example. Only onStart/onStop events working.
Steps to reproduce
Expected behavior onResume/onPause events are received when app goes to background
Additional context accompanist version = "0.32.0"
ok, so I was using confirmValueChange = { false } which is wrong for bottomSheet destination and may result navigator be out of sync
Description I have bottomSheet destination in my project and appropriate composable function that displays its content. Inside this function I listen to lifecycle events via DisposableEffect:
But onResume/onPause events are not received if I move app to background, for example. Only onStart/onStop events working.
Steps to reproduce
Expected behavior onResume/onPause events are received when app goes to background
Additional context accompanist version = "0.32.0"