Signal

class Signal<T>

A class representing a signal that can emit values of type T and allows other components to connect and react to these emitted values.

Parameters

T

The type of values that this signal emits.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val flow: SharedFlow<T>

Functions

Link copied to clipboard
fun connect(action: suspend (T) -> Unit): Connection

Connects an action to this signal using an internal scope. The action will be executed for each value emitted by this signal.

fun connect(scope: CoroutineScope, action: suspend (T) -> Unit): Job

Connects an action to this signal within the provided coroutine scope. The action will be executed for each value emitted by this signal.

Link copied to clipboard
suspend fun emit(value: T)

Emits a value to all collectors of this signal.

Link copied to clipboard
suspend fun emitWithParams(value: T, params: Map<String, Any?>)

Emits a signal with associated parameters to all collectors.

Link copied to clipboard
fun withParams(value: Any?, params: Map<String, Any?>): SignalData<Any?>

Creates a SignalData object with parameters, which can be emitted later.