connect

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.

Return

A Job that can be used to cancel the collection.

Parameters

scope

The coroutine scope in which to launch the collection.

action

A suspending function that takes a value of type T and performs an action.


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.

Note: It's recommended to use the scoped version of connect when possible for better lifecycle management.

Return

A connection that can be cancelled when no longer needed.

Parameters

action

A suspending function that takes a value of type T and performs an action.