NavEventNavigator

This allows to trigger navigation actions from outside the view layer without keeping references to Android framework classes that might leak. It also improves the testability of your navigation logic since it is possible to just write test that the correct events were emitted.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
val onBackPressedCallback: OnBackPressedCallback

Functions

Link copied to clipboard
open override fun backPresses(): Flow<Unit>

Returns a Flow that will emit Unit on every back press. While this Flow is being collected all back presses will be intercepted and none of the default back press handling happens.

open override fun <T> backPresses(value: T): Flow<T>

Returns a Flow that will emit value on every back press. While this Flow is being collected all back presses will be intercepted and none of the default back press handling happens.

Link copied to clipboard
open override fun <O : Parcelable> deliverNavigationResult(key: NavigationResultRequest.Key<O>, result: O)

Delivers the result to the destination that created key.

Link copied to clipboard
fun navigate(block: Navigator.() -> Unit)

Triggers a new NavEvent that collects and combines the nav events sent in the block so they can be handled individually.

Link copied to clipboard
open override fun navigateBack()

Triggers a new NavEvent that pops the back stack to the previous destination.

Link copied to clipboard
inline fun <T : NavRoute> Navigator.navigateBackTo(inclusive: Boolean = false)

Removes all entries from the backstack until T. If inclusive is true T itself will also be removed.

Link copied to clipboard
open override fun <T : BaseRoute> navigateBackToInternal(popUpTo: DestinationId<T>, inclusive: Boolean)

Removes all entries from the backstack until T. If inclusive is true T itself will also be removed.

Link copied to clipboard
open override fun navigateTo(route: NavRoute)

Triggers a new NavEvent to navigate to the given route.

Link copied to clipboard
open override fun navigateToRoot(root: NavRoot, restoreRootState: Boolean)

Triggers a new NavEvent to navigate to the given root. The current back stack will be popped and saved. Whether the backstack of the given root is restored depends on restoreRootState.

Link copied to clipboard
open override fun navigateUp()

Triggers a new NavEvent that causes up navigation.

Link copied to clipboard
open override fun replaceAll(root: NavRoot)

Replace the current back stack with the given root. The current back stack will cleared and the given root will be recreated. After this call the back stack will only contain the given root.

Link copied to clipboard
open override fun resetToRoot(root: NavRoot)

Reset the back stack to the given root. The current back stack will cleared and if root was already on it it will be recreated.