am a bit confused. when using `AnimatedNavHost` fr...
# compose
m
am a bit confused. when using
AnimatedNavHost
from
Accompanist
composable(...) {...}
is recomposed multiple times due to animation. so every value inside the
composable
lambda should be `remember`ed right? for extracting arguments it doesn't really matter because they are static but with
remember
we avoid constant extraction of arguments? what about
hiltViewModel
inside
composable
lambda? is it ok to do something like this:
Copy code
composable(
    route = Screen.Checkout.route,
    arguments = ...,
    enterTransition = { forwardTransitionSharedAxisXIn() },
    exitTransition = { backwardsTransitionSharedAxisXOut() },
) { backStackEntry ->
    val someArg = remember { backStackEntry.arguments!!.getFloat("arg") }
    val viewModel = hiltViewModel<CheckoutViewModel>(backStackEntry)
    CheckoutScreen(
        ...
        navigateUp = navController::popBackStack,
    )
}
?
i
I think you'll find the microsecond needed to do
getFloat
isn't ever actually going to impact your performance
m
I was actually asking about
hiltViewModel()
in example above, how will that behave
i
ViewModels are only created once; you're just accessing an already created object. Also fine
🦜 1
m
thank you very much