# ResultEventBus

Artifact: [androidx.navigation3:navigation3-runtime](https://developer.android.com/jetpack/androidx/releases/navigation3) [View Source](https://cs.android.com/search?q=file:androidx/navigation3/runtime/result/ResultEventBus.kt+class:androidx.navigation3.runtime.result.ResultEventBus) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigation3#1.2.0) Common/All
- Cmn

  ```
  class ResultEventBus
  ```

*** ** * ** ***

An EventBus for passing results between multiple sets of screens.

It provides solutions for both event and state based results.

For Event results, use a `https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEffect.composable#ResultEffect(androidx.navigation3.runtime.result.ResultEventBus,kotlin.coroutines.SuspendFunction1)` to receive all results.

For State results, use `https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#conflateAsState(kotlin.Any)` to get only the latest result for a particular key.

These results are not saved across configuration changes or process death.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#ResultEventBus()()` | Cmn |

| ### Public functions |
|---|---|---|
| `inline https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<T>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#conflateAsState(kotlin.Any)(defaultValue: T)` Provides a single `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` from the eventBus for the given class type. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<T>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#conflateAsState(kotlin.String,kotlin.Any)(resultKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, defaultValue: T)` Provides a single `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` from the eventBus for the given class type. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#removeResult()()` Removes all results associated with the given type from the store and stops the bus from providing any additional events. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#removeResult(kotlin.String)(resultKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Removes all results associated with the given key from the store and stops the bus from providing any additional events. | Cmn |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#sendResult(kotlin.Any)(result: T)` Sends a result into the channel associated with the given resultKey. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/navigation3/runtime/result/ResultEventBus#sendResult(kotlin.String,kotlin.Any)(resultKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, result: T)` Sends a result into the channel associated with the given resultKey. | Cmn |

## Public constructors

### ResultEventBus

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigation3#1.2.0)

```
ResultEventBus()
```

## Public functions

### conflateAsState

Cmn

```
@Composable
inline fun <T : Any?> conflateAsState(defaultValue: T): State<T>
```

Provides a single `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` from the eventBus for the given class type.

Developers should use this to retrieve result updates as `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State`.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | the type for the result to be returned as `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State`. |
| `defaultValue: T` | the default value for the state when none is available. |

### conflateAsState

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigation3#1.2.0)

```
@Composable
fun <T : Any?> conflateAsState(resultKey: String, defaultValue: T): State<T>
```

Provides a single `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` from the eventBus for the given class type.

Developers should use this to retrieve result updates as `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State`.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | the type of the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` return for the result. |
| `resultKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the key for the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` that will be returned. |
| `defaultValue: T` | the default value for the state when none is available. |

### removeResult

Cmn

```
inline fun <T : Any?> removeResult(): Unit
```

Removes all results associated with the given type from the store and stops the bus from providing any additional events.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | the type of the result to be removed. |

### removeResult

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigation3#1.2.0)

```
fun removeResult(resultKey: String): Unit
```

Removes all results associated with the given key from the store and stops the bus from providing any additional events.

| Parameters |
|---|---|
| `resultKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the key of the result to remove. |

### sendResult

Cmn

```
inline fun <T : Any?> sendResult(result: T): Unit
```

Sends a result into the channel associated with the given resultKey.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | the type of the result. |
| `result: T` | the result to send. |

### sendResult

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigation3#1.2.0)

```
fun <T : Any?> sendResult(resultKey: String, result: T): Unit
```

Sends a result into the channel associated with the given resultKey.

| Parameters |
|---|---|
| `resultKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the key for the result that is being sent. |
| `result: T` | the result to send. |