rememberAnsweringNavigator
inline fun <T : PopResult> rememberAnsweringNavigator(fallbackNavigator: Navigator, noinline block: suspend CoroutineScope.(result: T) -> Unit): GoToNavigator(source)
inline fun <T : PopResult> rememberAnsweringNavigator(backStack: BackStack<out BackStack.Record>, noinline block: suspend CoroutineScope.(result: T) -> Unit): GoToNavigator(source)
A reified version of rememberAnsweringNavigator. See documented overloads of this function for more information.
fun <T : PopResult> rememberAnsweringNavigator(fallbackNavigator: Navigator, resultType: KClass<T>, block: suspend CoroutineScope.(result: T) -> Unit): GoToNavigator(source)
Returns a GoToNavigator that answers with the given resultType or defaults to fallbackNavigator if no back stack is available to pass results through.
fun <T : PopResult> rememberAnsweringNavigator(backStack: BackStack<out BackStack.Record>, resultType: KClass<T>, block: suspend CoroutineScope.(result: T) -> Unit): GoToNavigator(source)
Returns a GoToNavigator that answers with the given resultType using the given backStack.
Handling of the result type T should be handled in the block parameter and is guaranteed to only be called at most once. It may never be called if the navigated screen never pops with a result (of equivalent type) back.
Note that resultType is a simple instance check, so subtypes may also be valid answers.
Example
val pickPhotoNavigator = rememberAnsweringNavigator(backStack, PickPhotoScreen.Result::class) { result: PickPhotoScreen.Result ->
// Do something with the result!
}
return State(...) { event ->
when (event) {
is PickPhoto -> pickPhotoNavigator.goTo(PickPhotoScreen)
}
}
// In PickPhotoScreen
navigator.pop(PickPhotoScreen.Result(...))
Content copied to clipboard