Highly recommend `EmptyImmutableSeq` iso Nil if you just need an empty
immutable Seq.


On Mon, May 26, 2014 at 5:56 PM, Roland Kuhn <notifications@github.com>wrote:

> In akka-stream/src/main/scala/akka/stream/impl/FlowImpl.scala:
>
> > +      var buf: Vector[Out] = Vector.empty
> > +
> > +      override def onNext(in: Out) = {
> > +        buf :+= in; Nil
> > +        if (buf.size == n) {
> > +          // start new time window
> > +          schedulePeriodically(timerName, d)
> > +          emitGroup()
> > +        } else Nil
> > +      }
> > +      override def onTermination(e: Option[Throwable]) = if (buf.isEmpty) Nil else List(buf)
> > +      override def onTimer(timerName: String) = emitGroup()
> > +      private def emitGroup(): immutable.Seq[immutable.Seq[Out]] = {
> > +        val group = buf
> > +        buf = Vector.empty
> > +        List(group)
>
> This is one way of doing it, but another useful way would be to do
>
> if (group.isEmpty) Nil else List(group)
>
> The rationale is that your version does not have the property that the
> grouped stream contains strictly less elements than the original one,
> making back pressure handling a bit questionable (depending on user
> expectations).
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/akka/akka/pull/15245/files#r13051280>
> .
>



-- 
Cheers,
√