mono

fun <T> mono(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T?): Mono<T>(source)

Creates a cold mono that runs a given block in a coroutine and emits its result. Every time the returned mono is subscribed, it starts a new coroutine. If the result of block is null, MonoSink.success is invoked without a value. Unsubscribing cancels the running coroutine.

Coroutine context can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.

Throws

if the provided context contains a Job instance.