split

fun Flow<ByteArray>.split(size: Int, operation: suspend (data: ByteArray, size: Int) -> List<ByteArray>): Flow<ByteArray>

Collects the flow of data and emits a new flow of chunked data using the given operation.

Return

A flow of chunked data.

Parameters

size

The maximum size of a chunk.

operation

The operation that will split the data into chunks.


fun Flow<ByteArray>.split(size: Int): Flow<ByteArray>

Collects the flow of data and emits a new flow of packet of at-most given size.

Return

A flow of packets.

Parameters

size

The maximum size of a packet.