janvladimirmostert
02/19/2022, 11:11 AMflow.take(1).collect {
println(it)
}
flow.take(4).collect {
println(it)
}
This is for parsing a byte flow that I'm reading from a socket, so in the case of take(4), it would be nice to do fold(4) that then spits out an Int
Just not sure what options there are to only read a limited number of bytes and then let the next flow operation continueRick Clephas
02/19/2022, 11:23 AMproduceIn
to convert your Flow
to a ReceiveChannel
and use receive
on that channel to only get a single element at a time. https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/produce-in.htmlAdam Powell
02/19/2022, 2:26 PMOrhan Tozan
02/19/2022, 2:28 PMjanvladimirmostert
02/19/2022, 3:01 PMOrhan Tozan
02/19/2022, 3:06 PMcorneil
02/20/2022, 5:58 PMjanvladimirmostert
02/22/2022, 5:43 PMcorneil
02/22/2022, 6:10 PMjanvladimirmostert
02/22/2022, 9:11 PM