Tony Kazanjian
04/29/2021, 5:44 AMremember{ mutableStateOf()}
instead of rememberSaveable{ mutableStateOf()}
? If you get saving across configuration and process death with the latter, why ever use the former?Andrew Max
04/29/2021, 7:20 AMAlbert Chang
04/29/2021, 8:01 AMrememberSaveable
whenever you want the value to survive process death but there definitely some situations where you don't need this. Besides, large objects can't be store in the bundle anyway.Albert Chang
04/29/2021, 8:02 AMTony Kazanjian
04/29/2021, 8:04 AMremember
it instead and perhaps have your ViewModel use a SaveStateHandler to get certain properties perhapsTony Kazanjian
04/29/2021, 8:22 AMremember
is good for caching results of expensive operations. Not sure why rememberSaveable
wouldn't be in the same situation, but perhaps there is a reason given the size constraints for a BundleMark Murphy
04/29/2021, 11:19 AMIf you get saving across configuration and process death with the latter, why ever use the former?Besides the size issue, bear in mind that not everything can be saved. You cannot save a socket across process termination, for example. The "saveable" data has to be something that can passed across process boundaries. We have been dealing with "what can we put in the saved instance state `Bundle`" concerns for ~13 years. This is just Compose's API on top of that. Also, I don't know if
rememberSaveable()
works on Compose for Desktop, as there is no saved instance state Bundle
outside of Android. Perhaps it falls back to behaving like normal remember()
on other platforms -- I have not tried it on Compose for Desktop yet.