iamthevoid
07/08/2021, 1:36 PMremember
function? What happens with remembered value when composable leave the composition? For exapmle
if (loading) {
Loading()
} else {
View(someLogic::calculateParam) // here inside remember 'someLogic::calculateParam' result has called
}
For example on next composition composition loading
is true, on next one false. In log i see that calculateResult changes, but what happens with previous? Is anywhere strong reference to it?iamthevoid
07/08/2021, 1:52 PMiamthevoid
07/08/2021, 1:53 PMiamthevoid
07/08/2021, 2:46 PMZach Klippenstein (he/him) [MOD]
07/08/2021, 2:58 PMI want to find a kind of callback or event when composition scope ceases to existand
I’d close scope when view absolutely closeare different things. If you want to take some action when a composable leaves the composition, use an effect. If you want to observe the underlying lifecycle, use
LocalLifecycleOwner
. But if you observe the lifecycle from a composable that leaves the composition before the lifecycle state changes, your observer won’t see the lifecycle changes (since it will have already been removed from the composition and removed as a lifecycle observer)iamthevoid
07/08/2021, 3:00 PMiamthevoid
07/09/2021, 7:21 AMLocalLifecycleOwner
only with Jetpack Compose Navigation, should i care about it? Looks like navigation handle lifecycle enoughZach Klippenstein (he/him) [MOD]
07/09/2021, 4:27 PMZach Klippenstein (he/him) [MOD]
07/09/2021, 4:32 PMiamthevoid
07/09/2021, 4:48 PMZach Klippenstein (he/him) [MOD]
07/09/2021, 5:41 PMbut inside onDestroy callback, not inside onStopWhy?
Zach Klippenstein (he/him) [MOD]
07/09/2021, 5:42 PMiamthevoid
07/09/2021, 5:55 PMiamthevoid
07/09/2021, 5:56 PMiamthevoid
07/09/2021, 5:57 PMiamthevoid
07/09/2021, 5:58 PMiamthevoid
07/09/2021, 5:58 PMiamthevoid
07/09/2021, 5:59 PMIan Lake
07/09/2021, 7:40 PMDisposableEffect
is the only cleanup available in Compose only code.Ian Lake
07/09/2021, 7:42 PMonCleared()
of every ViewModel
you create at the screen / navigation graph level (and also handles the configuration changes case for you as well)