MutableInteractionSource
interface MutableInteractionSource : InteractionSource
MutableInteractionSource represents a stream of Interactions corresponding to events emitted by
a component. These Interactions 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 androidx.compose.foundation.clickable and
androidx.compose.foundation.gestures.draggable have an MutableInteractionSource parameter,
which allows you to hoist an MutableInteractionSource and combine multiple interactions into
one event stream.
MutableInteractionSource exposes emit and tryEmit functions. These emit the provided
Interaction to the underlying interactions Flow, allowing consumers to react to these new
Interactions.
An instance of MutableInteractionSource can be created by using the MutableInteractionSource
factory function. This instance should be remembered before it is passed to other components
that consume it.
Functions
suspend fun emit(interaction: Interaction)
Emits interaction into interactions. This method is not thread-safe and should not be
invoked concurrently.
fun tryEmit(interaction: Interaction): Boolean
Tries to emit interaction into interactions without suspending. It returns true if the
value was emitted successfully.
