Package-level declarations

Utilities for Reactive Streams.

Functions

Link copied to clipboard
fun <T : Any> Publisher<T>.asFlow(): Flow<T>

Transforms the given reactive Publisher into Flow. Use the buffer operator on the resulting flow to specify the size of the back-pressure. In effect, it specifies the value of the subscription's request. The default buffer capacity for a suspending channel is used by default.

Link copied to clipboard
fun <T : Any> Flow<T>.asPublisher(context: CoroutineContext = EmptyCoroutineContext): Publisher<T>

Transforms the given flow into a reactive specification compliant Publisher.

Link copied to clipboard
suspend fun <T> Publisher<T>.awaitFirst(): T

Awaits the first value from the given publisher without blocking the thread and returns the resulting value, or, if the publisher has produced an error, throws the corresponding exception.

Link copied to clipboard
suspend fun <T> Publisher<T>.awaitFirstOrDefault(default: T): T

Awaits the first value from the given publisher, or returns the default value if none is emitted, without blocking the thread, and returns the resulting value, or, if this publisher has produced an error, throws the corresponding exception.

Link copied to clipboard
suspend fun <T> Publisher<T>.awaitFirstOrElse(defaultValue: () -> T): T

Awaits the first value from the given publisher, or calls defaultValue to get a value if none is emitted, without blocking the thread, and returns the resulting value, or, if this publisher has produced an error, throws the corresponding exception.

Link copied to clipboard
suspend fun <T> Publisher<T>.awaitFirstOrNull(): T?

Awaits the first value from the given publisher, or returns null if none is emitted, without blocking the thread, and returns the resulting value, or, if this publisher has produced an error, throws the corresponding exception.

Link copied to clipboard
suspend fun <T> Publisher<T>.awaitLast(): T

Awaits the last value from the given publisher without blocking the thread and returns the resulting value, or, if this publisher has produced an error, throws the corresponding exception.

Link copied to clipboard
suspend fun <T> Publisher<T>.awaitSingle(): T

Awaits the single value from the given publisher without blocking the thread and returns the resulting value, or, if this publisher has produced an error, throws the corresponding exception.

Link copied to clipboard
inline suspend fun <T> Publisher<T>.collect(action: (T) -> Unit)

Subscribes to this Publisher and performs the specified action for each received element.

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

Creates a cold reactive Publisher that runs a given block in a coroutine.