Is there a way to declare `NavHost` without state ...
# compose
p
Is there a way to declare
NavHost
without state restoration mechanism? I’d like to recompose it and return to start destination when state is lost.
i
Removing the composable that created the
rememberNavController()
and
NavHost
will certainly remove the state of that composable, but no, there's no way to purposefully throw away the user's state without throwing away the whole composables
What exactly do you mean by 'when state is lost'?
p
when system initiates process death
i
Then absolutely not, no. You should never, ever lose the user's state after process death and recreation
☝️ 1
Users taking a picture or answering a phone call should not reset their state in your app
p
Yes, I totally I agree. That’s desired scenario to always restore state. However, I’m unable to restore some logic in ViewModel, written in imperative approach (job that collects UI actions is cancelled along with ViewModel).
i
Sounds like you know what needs to be fixed
👍 1
p
I did a split up of shared view model by composable destinations and with the new architecture that issue disappeared. Process death is no longer an issue. Thanks @Ian Lake. 🙌
🎉 1