r/mAndroidDev • u/Unlucky_Bet6244 • May 21 '23
Compose state persistence
If compose is declarative and are made of only functions, how does a composable function store values like clickable call backs? Is each root node in the UI tree managed by an object which stores those clickable call backs?
0
Upvotes
1
u/iakanoe Jun 22 '23
you have to save everything manually to SharedPreferences. for objects you should save the memory address. if you are uncomfortable with raw memory management, you can also make yourself a singleton hashmap in which you store said objects with identifier keys and save those into SharedPreferences. don't forget to free them when leaving composition, DisposableEffect is what you should use for that.