In Akka Stream, I'd like a stream with a timer that emits an element every
n seconds. The timer should emit from a 1 element buffer that drops head on
overflow (meaning only keeps the newest element). So essentially emit the
newest element in intervals of n seconds. How can this be done?
My att
Hi. You were quite close. Instead of buffer.drophead use conflate which is
a rate detached operation. That allows upstream before conflate progress
faster than downstream after the conflate.
Source
.unfold(0) { e => Some((e + 1, e)) }
.conflate[Int] { case (_, e) => e }
.throttle(1, 1.second