Colton Idle
07/24/2026, 2:11 PMLifecycleStartEffect {
//start thing
onStopOrDispose {
//stop thing
}
}
is now deprecated to use without a key on the effect. My thought was that this is roughly an equivallent to activity's onStart. So what would the right key here be?
Is LifecycleEventEffect(Lifecycle.Even.ON_START) the better equivallent?Jonathan
07/24/2026, 4:30 PMUnit or whatever object you’re enacting inside of the effect be good?Ian Lake
07/24/2026, 7:15 PMDisposableEffect(Unit) a lot too? Same thing applies hereIan Lake
07/24/2026, 7:16 PM// stop thing on a different instance than you // start thing on. By using it as a key, you ensure that whenever the key changes, the old instance is `onStopOrDispose`'d and then the new instance is `// start thing`'dColton Idle
07/24/2026, 10:48 PMDo you DisposableEffect(Unit) a lot too? Same thing applies hereNope. I try not to use side effects, and can't say I remember the last time I used DisposableEffect. In a typical use case of using hilt + nav3 + VMs would you suspect that a "Screen" level Composable would have a
LifecycleStartEffect with the VM as the key?Ian Lake
07/24/2026, 10:52 PMIan Lake
07/24/2026, 10:52 PMColton Idle
07/25/2026, 2:35 AMLifecycleStartEffect { (omitting a key)Ian Lake
07/25/2026, 2:42 AMIan Lake
07/25/2026, 2:43 AMIan Lake
07/25/2026, 2:45 AMLifecycleEventEffect is much more likely to be the tool you should actually be reaching for and exactly why we offer the unpaired effect API at allColton Idle
07/25/2026, 3:02 AM