I'm trying to use `rememberSaveable` to persist a ...
# compose
m
I'm trying to use
rememberSaveable
to persist a generated value on device rotation. The problem I'm running into is that the path to get to the Composable function calling it changes based on the width size class of the device, which changes on rotation. This causes the machinery to think it is a new composable and calls the lambda passed to
rememberSaveable
again. I do want the value to be recalculated if the navigate away from that location and navigate back. My only thought is to pull the value all the way up to the part of the composable that knows whether the composable using
rememberSavable
will be called or not and then pass it down, but that's at a level that shouldn't know about or care about this value.
z
Sounds to me like whatever is deciding to call different code paths based on size should either support
rememberSaveable
explicitly, or better yet use
movableContentOf
to preserve all state.
m
Never heard of
moveableContentOf
. I'll look into it, but that sounds like what I want.
z
It’s kinda relatively newish, maybe a year old or so
But this was one of the explicit use cases it was intended for
m
I thought there must be a tool for it.