fun <T> flux(context: CoroutineContext = EmptyCoroutineContext, block: suspend ProducerScope<T>.() -> Unit): Flux<T>(source)

Creates a cold reactive Flux that runs the given block in a coroutine. Every time the returned flux is subscribed, it starts a new coroutine in the specified context. The coroutine emits (Subscriber.onNext) values with send, completes (Subscriber.onComplete) when the coroutine completes, or, in case the coroutine throws an exception or the channel is closed, emits the error (Subscriber.onError) and closes the channel with the cause. Unsubscribing cancels the running coroutine.

Invocations of send are suspended appropriately when subscribers apply back-pressure and to ensure that onNext is not invoked concurrently.

Note: This is an experimental api. Behaviour of publishers that work as children in a parent scope with respect to cancellation and error handling may change in the future.


if the provided context contains a Job instance.