Othman El Jazouli
10/17/2022, 5:46 PMremember{}
states and pretty much not reload a screen A, when navigating to another composable B and back press to A, I see that everything is cleared as if A is starting from scratchagrosner
10/17/2022, 6:02 PMrememberSaveable
agrosner
10/17/2022, 6:03 PMagrosner
10/17/2022, 6:03 PMritesh
10/17/2022, 6:41 PMrememberSaveable
here, as it's more suitable for re-creation or process-death.
Instead hoist the state all the way up to vm.agrosner
10/17/2022, 6:55 PMOthman El Jazouli
10/17/2022, 9:36 PM@Composable
fun MyComposable(
viewModel: MyViewModel = getViewModel(scope = myScope),
...
) {
...
and then I initiate the first call with
DisposableEffect(key1 = viewModel) {
viewModel.doSomething()
onDispose { }
}
Othman El Jazouli
10/17/2022, 10:10 PMviewModel.doSomething()
is triggered again,
is there a way in compose to make this a one time call? or do I also have to store the state in the vm?Othman El Jazouli
10/17/2022, 10:11 PMDisposableEffect(key1 = null)
it’s always triggeredIan Lake
10/18/2022, 2:22 AMinit
or a by lazy