This allows screens to use LifecycleResumeEffect to perform actions that should only be done once the screen is ready to be interacted with. The biggest use case for this is requesting focus.
E.g. This is wrong, because it will (1) request the keyboard as soon as the animation starts, at which point the thing requesting focus isn't even visible on the screen, and (2) if predictive back is supported, the focus will be stolen by the previous screen as soon as the back gesture begins, even if it's later cancelled.
DisposableEffect(focusRequester) {
focusRequester.requestFocus()
onDispose {}
}
If we make this change, then the code can instead be:
LifecycleResumeEffect(focusRequester) {
focusRequester.requestFocus()
onPauseOrDispose {}
}
There is precedent for this change: The new Jetpack Nav3 library has this behavior already. We also discussed in Slack.