rememberNavigationEventState

Functions summary

NavigationEventState<T>
@Composable
<T : NavigationEventInfo> rememberNavigationEventState(
    currentInfo: T,
    backInfo: List<T>,
    forwardInfo: List<T>
)

Remembers and returns a NavigationEventState instance.

Cmn

Functions

rememberNavigationEventState

@Composable
fun <T : NavigationEventInfo> rememberNavigationEventState(
    currentInfo: T,
    backInfo: List<T> = emptyList(),
    forwardInfo: List<T> = emptyList()
): NavigationEventState<T>

Remembers and returns a NavigationEventState instance.

This composable creates and remembers a NavigationEventState object, which holds a NavigationEventHandler internally. This is the state object that can be passed to NavigationEventHandler (the composable) to "hoist" the state.

The state's handler info (currentInfo, backInfo, forwardInfo) is kept in sync with the provided parameters via a SideEffect.

Parameters
<T : NavigationEventInfo>

The type of NavigationEventInfo this state will manage.

currentInfo: T

The object representing the current destination.

backInfo: List<T> = emptyList()

A list of destinations the user may navigate back to (nearest-first).

forwardInfo: List<T> = emptyList()

A list of destinations the user may navigate forward to (nearest-first).

Returns
NavigationEventState<T>

A stable, remembered NavigationEventState instance.