Marcin Wisniowski
06/03/2024, 5:32 PMLifecycleEventEffect(ON_START) {
println("Start")
}
LifecycleEventEffect(ON_CREATE) {
println("Create")
}
With this code, "Start" will be printed before "Create" (it's ran in-place because the lifecycle is already past the started state), which can be problematic, and doesn't work the same way as the equivalent callbacks in an Android Activity. Code in the ON_START effect can depend on something in ON_CREATE being created.
What's the solution to this?
Ordering the code the other way around of course works, but is not always possible, and the effects may be defined a few functions deep in unrelated code.Ian Lake
06/03/2024, 5:38 PMMarcin Wisniowski
06/03/2024, 5:57 PMStylianos Gakis
06/03/2024, 5:58 PMMarcin Wisniowski
06/03/2024, 6:06 PMStylianos Gakis
06/03/2024, 6:08 PMMarcin Wisniowski
06/03/2024, 6:14 PMStylianos Gakis
06/03/2024, 6:14 PMIan Lake
06/03/2024, 6:15 PMcomposable
destination we provide in your own wrapper that automatically adds your logging as the first LifecycleEventEffect before calling the content
lambda - that's an easy way to guarantee the wrappers around each screen are in the order you want