about the new `retain` api -- stupid question but ...
# compose
u
about the new
retain
api -- stupid question but how is that different from just holding the reference statically?
j
Retain still has a defined lifecycle. Statics match the process lifecycle.
We retain while a screen is in the back stack, for example, and propagate that across the activity non config instance during config change
But if you leave the back stack we clear that state
u
hmm how does a composable know about a backstack? do you mean a nav lib has to "implement"something from the retain package in order for it to work?
j
Yes
Our back stack provides the lifecycle of each retain scope
u
so.. out of the box, without a nav lib, its going to be same as a static ref?
j
Out of the box it'll probably do nothing
k
If I enable the restrict background activity setting, what happened to the retained things, will them be cleared?
u
they wont survive process restore
👍 1