[akka-user] [akka-stream] How to emit the newest element every n seconds?

2016-07-29 Thread Dominykas Mostauskis
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

Re: [akka-user] [akka-stream] How to emit the newest element every n seconds?

2016-08-05 Thread Martynas Mickevičius
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