https://kotlinlang.org logo
#compose
Title
# compose
e

enighma

03/31/2022, 11:36 PM
Re: Compose Navigation Is there any sane/preferred way to create the NavHostController outside of compose, but still be able to setup your navhost using it? In my use case I’m thinking of injecting a nav controller into my VMs, since they are responsible for taking actions on my navigation events (at least in my current arch).
The Architecting your Compose UI talks about treating events as state: https://developer.android.com/jetpack/compose/architecture#example
and the Guide to App Architecture has a whole page on UI events, with a special section specifically on events from a ViewModel: https://developer.android.com/jetpack/guide/ui-layer/events#handle-viewmodel-events
e

enighma

04/04/2022, 6:20 PM
It looks like the suggestion is what we’re currently doing, but thanks for the reference as it underlines what I thought.
3 Views