rocketraman
04/17/2021, 12:35 AMflow.transformLatest { value ->
while(currentCoroutineContext().isActive) {
emit(value)
delay(x)
}
}
Steffen Funke
04/17/2021, 7:35 AMcombine
a timer (for the "periodical every x seconds part"), and my actual flow, like this:
// the timer
val timer = (0..Int.MAX_VALUE).asSequence().asFlow().onEach { delay(1_000) }
// your other flow
val other = flow {
emit("A")
delay(1500L)
emit("B")
delay(1500L)
emit("C")
}
// combine them
launch {
combine(timer, other, ::Pair)
.collect { (timer, other) ->
println("bling: ${timer} | ${other}")
}
}
Steffen Funke
04/17/2021, 7:40 AMrocketraman
04/17/2021, 5:54 PMokarm
04/20/2021, 10:53 PMrocketraman
04/20/2021, 10:55 PMrocketraman
04/20/2021, 10:58 PMtransformLatest
approach?okarm
04/20/2021, 11:08 PM