https://kotlinlang.org logo
Title
j

Jiri Bruchanov

10/06/2021, 7:08 PM
Hi anyone who would know ? I'm trying to do a flow of ints and trying to detect if the sequence is increasing or decreasing based on last 2 numbers...
so doing like
val flow = MutableSharedFlow<Int>()
flow.tryEmit(1)
flow.tryEmit(2)
flow.tryEmit(3)
and was hoping to do something like following, but that doesn't worj
flow
.zip(flow.drop(1)) { x, y -> y - x}
.collect { incOrDec ->
	println(incOrDec)
}
c

Cedrick Cooke

10/06/2021, 7:32 PM
There's an implementation of
zipWithNext
in the comments of this issue: https://github.com/Kotlin/kotlinx.coroutines/issues/1767
👍 1