Hello guys! Another amazing day with compose, one ...
# compose
m
Hello guys! Another amazing day with compose, one question I have a nested navigation graph with 3 composable like this (they are 3 step of signup screen)
Copy code
navigation(startDestination = "step1", route = "signup") {
    composable(route = "step1") {
        Step1Screen(hiltViewModel<SignUpViewModel>())
    }
    composable(route = "step2") {
        Step2Screen(hiltViewModel<SignUpViewModel>())
    }
    composable(route = "step3") {
        Step2Screen(hiltViewModel<SignUpViewModel>())
    }
}

composable(MainRoutes.ConfirmEmail) {
    ...
}
my goal is to have the same
SignUpViewModel
instance in the three composable. With the current implementation each screens have a different instance (so I lost previous steps states). Any idea to handle this scenario? Because a different solution is to use another NavHost with a different NavigatrionController, but I would avoid it
h
Please use the search for this every day question: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1630006449086300
🙌 1
👆 1
c
NavGraphScoped view models is the answer. Good luck!
🙌 1