# MutableInteractionSource

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/interaction/InteractionSource.kt+class:androidx.compose.foundation.interaction.MutableInteractionSource) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0) Common/All
- Cmn

  ```
  interface MutableInteractionSource : InteractionSource
  ```

*** ** * ** ***

MutableInteractionSource represents a stream of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s corresponding to events emitted by a component. These `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s can be used to change how components appear in different states, such as when a component is pressed or dragged.

Lower level interaction APIs such as `https://developer.android.com/reference/kotlin/androidx/compose/foundation/clickable.modifier#(androidx.compose.ui.Modifier).clickable(kotlin.Boolean,kotlin.String,androidx.compose.ui.semantics.Role,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function0)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/draggable.modifier#(androidx.compose.ui.Modifier).draggable(androidx.compose.foundation.gestures.DraggableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Boolean,kotlin.coroutines.SuspendFunction2,kotlin.coroutines.SuspendFunction2,kotlin.Boolean)` have an `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` parameter, which allows you to hoist an `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and combine multiple interactions into one event stream.

MutableInteractionSource exposes `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#emit(androidx.compose.foundation.interaction.Interaction)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#tryEmit(androidx.compose.foundation.interaction.Interaction)` functions. These emit the provided `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction` to the underlying `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`, allowing consumers to react to these new `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s.

An instance of MutableInteractionSource can be created by using the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` factory function. This instance should be `https://developer.android.com/reference/kotlin/androidx/compose/runtime/remember.composable#remember(kotlin.Function0)`ed before it is passed to other components that consume it.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction` |   |

## Summary

| ### Public functions |
|---|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#emit(androidx.compose.foundation.interaction.Interaction)(interaction: https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction)` Emits `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#emit(androidx.compose.foundation.interaction.Interaction)` into `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#tryEmit(androidx.compose.foundation.interaction.Interaction)(interaction: https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction)` Tries to emit `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#tryEmit(androidx.compose.foundation.interaction.Interaction)` into `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()` without suspending. | Cmn |

### Inherited properties

From [androidx.compose.foundation.interaction.InteractionSource](https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource) `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction>` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()`

`https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` representing the stream of all `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s emitted through this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource`.
Cmn

## Public functions

### emit

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
suspend fun emit(interaction: Interaction): Unit
```

Emits `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#emit(androidx.compose.foundation.interaction.Interaction)` into `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()`. This method is not thread-safe and should not be invoked concurrently.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#tryEmit(androidx.compose.foundation.interaction.Interaction)` |   |

### tryEmit

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
fun tryEmit(interaction: Interaction): Boolean
```

Tries to emit `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#tryEmit(androidx.compose.foundation.interaction.Interaction)` into `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()` without suspending. It returns `true` if the value was emitted successfully.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource#emit(androidx.compose.foundation.interaction.Interaction)` |   |