launchMolecule

fun <T> CoroutineScope.launchMolecule(mode: RecompositionMode, context: CoroutineContext = EmptyCoroutineContext, body: @Composable () -> T): StateFlow<T>

Launch a coroutine into this CoroutineScope which will continually recompose body to produce a StateFlow stream of T values.

The coroutine context is inherited from the CoroutineScope. Additional context elements can be specified with context argument.


fun <T> CoroutineScope.launchMolecule(mode: RecompositionMode, emitter: (value: T) -> Unit, context: CoroutineContext = EmptyCoroutineContext, body: @Composable () -> T)

Launch a coroutine into this CoroutineScope which will continually recompose body in the optional context to invoke emitter with each returned T value.

launchMolecule's emitter is always free-running and will not respect backpressure. Use moleculeFlow to create a backpressure-capable flow.

The coroutine context is inherited from the CoroutineScope. Additional context elements can be specified with context argument.