useReceive

inline suspend fun <T, R> ChannelWithCloseableData<T>.useReceive(block: (T) -> R): R(source)

Receives data from the channel and uses it in a block, ensuring that the data is properly closed after use.

Return

The result of the block execution.

Parameters

block

The block of code to execute with the received data.