asFlow

fun <T : Any> Publisher<T>.asFlow(): Flow<T>(source)

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.

If any of the resulting flow transformations fails, the subscription is immediately cancelled and all the in-flight elements are discarded.

This function is integrated with ReactorContext from kotlinx-coroutines-reactor module, see its documentation for additional details.