Package kotlinx.coroutines.reactive

Utilities for Reactive Streams.

Types

PublisherCoroutine

class PublisherCoroutine<in T> : 
    AbstractCoroutine<Unit>,
    ProducerScope<T>,
    Subscription,
    SelectClause2<T, SendChannel<T>>

Extensions for External Classes

kotlinx.coroutines.CoroutineScope

kotlinx.coroutines.channels.ReceiveChannel

kotlinx.coroutines.flow.Flow

org.reactivestreams.Publisher

Functions

publish

fun <T> publish(
    context: CoroutineContext = EmptyCoroutineContext,
    block: suspend ProducerScope<T>.() -> Unit
): Publisher<T>

Creates cold reactive Publisher that runs a given block in a coroutine. Every time the returned publisher is subscribed, it starts a new coroutine. Coroutine emits items with send. Unsubscribing cancels running coroutine.