Represents the given receive channel as a hot flow and receives from the channel in fan-out fashion every time this flow is collected. One element will be emitted to one collector only.

See also consumeAsFlow which ensures that the resulting flow is collected just once.

Cancellation semantics

  • Flow collectors are cancelled when the original channel is closed with an exception.

  • Flow collectors complete normally when the original channel is closed normally.

  • Failure or cancellation of the flow collector does not affect the channel.

Operator fusion

Adjacent applications of flowOn, buffer, conflate, and produceIn to the result of receiveAsFlow are fused. In particular, produceIn returns the original channel. Calls to flowOn have generally no effect, unless buffer is used to explicitly request buffering.