# rememberNavigationEventDispatcherOwner

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/navigationevent/compose/rememberNavigationEventDispatcherOwner.composable#rememberNavigationEventDispatcherOwner(kotlin.Boolean,androidx.navigationevent.NavigationEventDispatcherOwner)( enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, parent: https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner? )` Remembers a new `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` which creates a dispatcher linked to a parent dispatcher found in the composition. | Cmn |

## Functions

### rememberNavigationEventDispatcherOwner

Cmn Artifact: [androidx.navigationevent:navigationevent-compose](https://developer.android.com/jetpack/androidx/releases/navigationevent) [View Source](https://cs.android.com/search?q=file:androidx/navigationevent/compose/RememberNavigationEventDispatcherOwner.kt+function:rememberNavigationEventDispatcherOwner) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.0.0)

```
@Composable
fun rememberNavigationEventDispatcherOwner(
    enabled: Boolean = true,
    parent: NavigationEventDispatcherOwner? = checkNotNull(LocalNavigationEventDispatcherOwner.current) {
            "No NavigationEventDispatcherOwner provided in LocalNavigationEventDispatcherOwner. " +
                "If you intended to create a root dispatcher, explicitly pass null as the parent."
        }
): NavigationEventDispatcherOwner
```

Remembers a new `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` which creates a dispatcher linked to a parent dispatcher found in the composition.

This composable creates a dispatcher that links to any parent dispatcher found in the composition, forming a parent-child relationship. If no parent exists, it automatically becomes a new root dispatcher, this is the top-most parent in a hierarchy. This is useful for isolating navigation handling within specific UI sections, such as a self-contained feature screen or tab.

The dispatcher's lifecycle is automatically managed. It is created only once and automatically disposed of when the composable leaves the composition, preventing memory leaks.

When used to create a root dispatcher, you must use a `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventInput` to send it events. Otherwise, the dispatcher will be detached and will not receive events.

To provide the new `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` to a sub-composition, use `https://developer.android.com/reference/kotlin/androidx/compose/runtime/CompositionLocalProvider.composable#CompositionLocalProvider(kotlin.Array,kotlin.Function0)`:

androidx.navigationevent.compose.samples.RememberNavigationEventDispatcherOwner

**Null parent:** If `https://developer.android.com/reference/kotlin/androidx/navigationevent/compose/package-summary#rememberNavigationEventDispatcherOwner(kotlin.Boolean,androidx.navigationevent.NavigationEventDispatcherOwner)` is **EXPLICITLY** `null`, this creates a root dispatcher that runs independently. By default, it requires a parent from the `https://developer.android.com/reference/kotlin/androidx/navigationevent/compose/LocalNavigationEventDispatcherOwner` and will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` if one is not present.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | Controls if the dispatcher is active. If this value changes, the dispatcher's `isEnabled` property will be updated. When `false`, this dispatcher and any of its children will not receive events. Defaults to `true`. |
| `parent: https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner? = checkNotNull(LocalNavigationEventDispatcherOwner.current) { "No NavigationEventDispatcherOwner provided in LocalNavigationEventDispatcherOwner. " + "If you intended to create a root dispatcher, explicitly pass null as the parent." }` | The `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` to use as the parent, or `null` if it is a root. Defaults to the owner from `https://developer.android.com/reference/kotlin/androidx/navigationevent/compose/LocalNavigationEventDispatcherOwner`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` | A new `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` that is remembered across compositions. |