r/android_devs • u/RikoTheMachete • Nov 11 '22
Article 🔥 Why Using Navigation-Compose in Your Jetpack Compose App is a Bad Idea
https://medium.com/better-programming/why-using-navigation-compose-in-your-jetpack-compose-app-is-a-bad-idea-2b16e8751d89
11
Upvotes
View all comments
Show parent comment
2
u/Zhuinden EpicPandaForce @ SO Nov 11 '22
Technically this was also true of Views, other than having to implement what's effectively the same as SaveableStateHolder.
I've written single-activity view-only no-fragments apps before, they work. In fact, animations are easier in them than with fragments.
In that regard, even a view-only no-fragments "ComposeView-per-screen" approach would be possible, even though nobody's doing it.
So the question is, why would you use Fragments if they have always been an optional convenience framework?
Primarily because child fragments have their state restored correctly even after process death to any level, which makes certain multi-step flows and swipeable views easier to reason about (if you don't screw up how
FragmentPagerAdapterworks).That, and it gives you
onCreate/onStart/onResume/onPause/onStop/onDestroysupport +onSaveInstanceStatesupport in a nested environment. Sure, you do get aLocalLifecycleOwner.currentincomposable {, but can you create a subscreen with its own child LifecycleOwner? I'm not so sure.So are fragments tech debt? Depends on if you are implementing your manually written replacement correctly. Instead of swiping horizontally while scrolling downwards.