remember Navigation Controller
fun rememberNavigationController(startDestinations: List<Destination>, onScreenChange: (debugInfo: String) -> Unit = {}, resultTtl: Duration = DEFAULT_RESULT_TTL): NavigationController
Creates a controller with its own ResultStore.
Parameters
start Destinations
The full list of start destinations. For each unique Destination.Args.backstackIndex you must provide a start Destination.
result Ttl
Time-to-live for stored results: unconsumed results are discarded after this duration. Example:
val controller = rememberNavigationController(
startDestinations = listOf(HomeDestination()),
)Content copied to clipboard
fun rememberNavigationController(startDestinations: List<Destination>, onScreenChange: (debugInfo: String) -> Unit = {}, resultSource: ResultSource): NavigationController
Creates a controller backed by the provided resultSource. Pass the same source to application wrappers when they need to observe results independently of the controller.
Parameters
start Destinations
The full list of start destinations. For each unique Destination.Args.backstackIndex you must provide a start Destination.
result Source
The source shared with the controller. Keep the instance stable and alive for at least as long as the wrappers observing it. Example:
// DI or ViewModel scope
val resultSource = ResultSource.create()
val wrapper = ResultsWrapper(resultSource)
// Composition
val controller = rememberNavigationController(
startDestinations = listOf(HomeDestination()),
resultSource = resultSource,
)Content copied to clipboard