tseisel
07/26/2022, 6:52 PMval source = flow {
emit("A")
delay(100)
emit("B")
delay(50)
emit("C")
emit("D")
}
when applied a constraint of "max 1 element each 100ms", it should emit:
• "A" at t = 0ms
• "B" at t = 100ms
• "D" at t = 200msNick Allen
07/26/2022, 7:42 PMsource
.conflate()
.transform {
emit(it)
delay(100)
}
Conflate will keep track of the most recently emitted value during the delay(100)
from the previous value.rnett
07/26/2022, 8:12 PMdebounce
does this in one stepNick Allen
07/26/2022, 11:42 PMsource.debounce(100)
would maybe give "A" at 100ms and would emit "D" at 250ms.tseisel
07/27/2022, 10:19 AMthrottleLatest
Rx operator for so long that I couldn't imagine it would be so simple 😵
The best part with your code is that we can also get throttleFirst
by replacing conflate()
with buffer(0, BufferOverflow.DROP_LATEST)
.