myFlow.previousMap { previousValue, currentValue -...
# coroutines
n
myFlow.previousMap { previousValue, currentValue -> }
w
You’re likely looking for a
scan
or
runningReduce
operator
n
oh i didn't know about runningReduce
but it will replay each emitted value for each new value right ?
I'll do some tests
d
zipWithNext?
n
ok runningReduce was exactly what I was looking for, thank you @wasyl
👍 3
c
@Dominaezzz that was my first thought, but it doesn’t look like
zipWithNext
is defined for Flow. But the issue requesting it does have a simple implementation of that operator https://github.com/Kotlin/kotlinx.coroutines/issues/1767
👍 1
n
and using flow for byte-by-byte transfer is not ideal either.
I wonder why though
d
You could compare it to reading a file into memory, byte by byte, instead of in chunks.
n
yes but what would be better than flow for this use case ? channels ?
d
Flow of byte buffers maybe.
r
@nitrog42 Take a look at how Okio works. It’s very elegant and is 100% in Kotlin as of 2018 https://square.github.io/okio/
I believe they also have plans to integrate coroutine usage into the library as well
n
oh i know about okio 😄
I definitelly use it when I can
💯 1