With `BackHandler` and `mutableState`, do you stil...
# compose
h
With
BackHandler
and
mutableState
, do you still use Google androidx navigation library or simple a state based approach?
p
I would like to use a declarative approach to navigation but haven’t been lucky in finding something tried and tested. And I’m not too experienced in Android / compose lifecycle to make suggestions on how to do it, unfortunately. But coming from SwiftUI, this is basically the only thing that’s missing in Compose.
i
It is certainly nice to know that all of the same building blocks that are available to a library like Navigation are also available for you to use if you don't need: • A
LifecycleOwner
scoped to each screen (e.g., for scoping the collecting of Flows that are Lifecycle aware) • Out of the box support for
rememberSaveable
at a screen by screen basis • Full recovery of state after configuration changes or process death and recreation • Support for ViewModels and injection via Hilt ViewModels • Built in support for handling deep links • Extensibility to allow for dialogs, bottom sheets, etc. with all the same benefits as full screen destinations • Support for controlling the transitions between screens (via Accompanist Navigation at the moment)
You may need none of those for your first prototype (and Navigation does not require you to know or care about any of those since they all come for free), but being able to iteratively add them without throwing out your entire navigation system can certainly save a lot of rework over time
There's certainly quite a few other navigation libraries for Compose though, if another one fits your needs better (i.e., Decompose's support for KMP) you are certainly not beholden to use AndroidX Navigation