Skip to content

Commit

Permalink
Merge "Apply owners and the graph as part of composition" into androi…
Browse files Browse the repository at this point in the history
…dx-main
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Jul 15, 2021
2 parents dffae20 + 47546f5 commit 5e67171
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,15 @@ public fun NavHost(
val onBackPressedDispatcherOwner = LocalOnBackPressedDispatcherOwner.current
val onBackPressedDispatcher = onBackPressedDispatcherOwner?.onBackPressedDispatcher

// on successful recompose we setup the navController with proper inputs
// after the first time, this will only happen again if one of the inputs changes
DisposableEffect(navController, lifecycleOwner, viewModelStoreOwner, onBackPressedDispatcher) {
navController.setLifecycleOwner(lifecycleOwner)
navController.setViewModelStore(viewModelStoreOwner.viewModelStore)
if (onBackPressedDispatcher != null) {
navController.setOnBackPressedDispatcher(onBackPressedDispatcher)
}

onDispose { }
// Setup the navController with proper owners
navController.setLifecycleOwner(lifecycleOwner)
navController.setViewModelStore(viewModelStoreOwner.viewModelStore)
if (onBackPressedDispatcher != null) {
navController.setOnBackPressedDispatcher(onBackPressedDispatcher)
}

SideEffect { navController.graph = graph }
// Then set the graph
navController.graph = graph

val saveableStateHolder = rememberSaveableStateHolder()

Expand Down

0 comments on commit 5e67171

Please sign in to comment.