bryankeltonadams
01/26/2024, 10:34 PMStylianos Gakis
01/26/2024, 10:41 PMbryankeltonadams
01/27/2024, 12:02 AMStylianos Gakis
01/27/2024, 9:41 AMbryankeltonadams
01/27/2024, 10:58 PMbryankeltonadams
01/27/2024, 11:06 PMStylianos Gakis
01/28/2024, 8:48 AMbryankeltonadams
01/28/2024, 6:14 PMStylianos Gakis
01/28/2024, 10:33 PMbryankeltonadams
01/29/2024, 12:02 AMlouiscad
01/29/2024, 10:16 AMbryankeltonadams
01/29/2024, 4:30 PMbryankeltonadams
03/04/2024, 5:51 PMStylianos Gakis
03/04/2024, 5:56 PMLocalLifecycleOwner.current.lifecycle
and make sure that it’s RESUMED before you do anything.
As soon as you start animating into another screen, it immediately sets the lifecycle to something higher than RESUMEDStylianos Gakis
03/04/2024, 5:57 PM@Composable
private fun whenLifecycle(
state: State,
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
onState: () -> Unit,
): () -> Unit {
require(state != State.DESTROYED) {
"Target state is not allowed to be `Lifecycle.State.DESTROYED` because Compose disposes " +
"of the composition before `Lifecycle.Event.ON_DESTROY` observers are invoked."
}
return {
if (lifecycleOwner.lifecycle.currentState == state) {
onState()
}
}
}
Here is the API https://android-review.googlesource.com/c/platform/frameworks/support/+/2944594/3/lifecycle/[…]main/java/androidx/lifecycle/compose/WhenLifecycle.kt which is gonna be included soon in the compose lifecycle artifact (lifecycle-runtime-compose) itself, but for now you can do it yourselfStylianos Gakis
03/04/2024, 6:11 PMbryankeltonadams
03/06/2024, 5:35 PM