raamcosta / compose-destinations

Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
https://composedestinations.rafaelcosta.xyz
Apache License 2.0
3.23k stars 134 forks source link

Inquiry about dependenciesContainerBuilder #695

Open yoobi opened 1 month ago

yoobi commented 1 month ago

Hi, just a quick question about dependenciesContainerBuilder

I've created a wrapper called Navigator which I set in my MainActivity with a DisposableEffect. Is it alright to pass such objet to dependenciesContainerBuilder ?

val composableNavigator = ComposableNavigator.rememberNavigator() // Creates navController, bottomSheetState etc...
DisposableEffect(key1 = composableNavigator) {
    navigator.setNavigation(composableNavigator.navController)
    onDispose {
        navigator.clearNavigation()
    }
}
ModalBottomSheetLayout(...) {
    DestinationsNavHost(
        dependenciesContainerBuilder = {
            dependency(navigator)
        },
        navController = navController,
        navGraph = NavGraphs.root,
        startRoute = startRoute
    )
}