Marco Pierucci
05/09/2023, 11:10 PMremember
function that saves the state in a similar way AAC survive configuration changes?
Any Google devs here know if something like this is even on the radar?ephemient
05/09/2023, 11:15 PMMarco Pierucci
05/09/2023, 11:17 PMPablichjenkov
05/09/2023, 11:19 PMephemient
05/09/2023, 11:21 PMPablichjenkov
05/09/2023, 11:23 PMMarco Pierucci
05/09/2023, 11:24 PMAnd we've always been told there is a limti to Bundle storage and not to sore complex datastores UI element state in arememberSaveable
through the saved instance state mechanism.Bundle
Pablichjenkov
05/09/2023, 11:24 PMephemient
05/09/2023, 11:25 PMMarco Pierucci
05/09/2023, 11:25 PMgetLastNonConfigurationInstance()
with that as well ( which in that case I learnt something. new today)Pablichjenkov
05/09/2023, 11:26 PMMarco Pierucci
05/09/2023, 11:27 PMephemient
05/09/2023, 11:29 PMMarco Pierucci
05/09/2023, 11:29 PMephemient
05/09/2023, 11:29 PMMarco Pierucci
05/09/2023, 11:29 PMif you merely want to survive configuration changes then Compose already just worksThats not the case, at least not by default, you need to disable all configuration changes on your activity for that to be the case. And there are changes that cant be disabled
Pablichjenkov
05/10/2023, 12:28 AMobject
that holds your data during the configuration transition. The key is detecting when the transition is going to happen. You can place a DisposableEffect in your root composable and place your data in the holder object in the disposing lambda then recover the data when the composable starts, making the holder reference null after so it doesn't leak, it just hold it for a couple of milliseconds.
Or perhaps instead of having a DisposableEffect in your root composable you can just listen for Activity lifecycle and do the same in onDestroy/onCreateMarco Pierucci
05/10/2023, 11:44 AMPablichjenkov
05/10/2023, 12:27 PMMarco Pierucci
05/10/2023, 4:58 PM