zsperske
12/08/2020, 1:59 AMNavHost
s? Or should the entire graph be defined at the top level?allan.conda
12/08/2020, 2:00 AMzsperske
12/08/2020, 2:01 AMIan Lake
12/08/2020, 3:53 AMzsperske
12/08/2020, 3:53 AMIan Lake
12/08/2020, 4:01 AMval navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.arguments?.getString(KEY_ROUTE)
if (currentRoute != "login") {
}
zsperske
12/08/2020, 4:03 AMIan Lake
12/08/2020, 4:04 AMzsperske
12/08/2020, 4:04 AMIan Lake
12/08/2020, 4:10 AMzsperske
12/08/2020, 4:13 AMManuel Vivo
12/09/2020, 9:22 AMLoginRepository
scoped to a login flow, I’d create a nested graph and scope the LoginRepo to its VMIan Lake
12/09/2020, 3:24 PMManuel Vivo
12/09/2020, 4:43 PMUserRepository
that can be scoped to the Application
. However, for something like a LoginRepository
that is in charge of making the auth calls, I just want it in memory for a short period of time (but potentially reusable across multiple login screens)NavHost
. right?navGraphViewModels
works in Compose navigation but I’m not sure about itIan Lake
12/09/2020, 4:58 PMUserRepository
, that certainly makes sensenavigation
tag in the DSL. Yes, with a nested graph, you can scope ViewModels, etc. at the graph level. We're still working on what a nice API for that would look like, but you can see an example in this answer: https://stackoverflow.com/a/64961032/1676363Manuel Vivo
12/09/2020, 5:01 PMallan.conda
12/10/2020, 4:56 AMjulioromano
05/28/2021, 12:24 PMWe’re still working on what a nice API for that would look like, but you can see an example in this answer@Ian Lake is there any update for this use case (i.e. scoping a VM to a nested nav graph)? Has a public API landed?
hiltNavGraphViewModel()
Is now deprecated in favor of hiltViewModel()
but it doesn’t seem it supports nested nav graph scoping yet.
Should we still apply the temp solution at: https://stackoverflow.com/a/64961032/1676363 ?Ian Lake
06/01/2021, 7:03 PMval sharedViewModel = hiltViewModel(navController.getBackStackEntry("nested_nav"))
works just fine