scalaakkaakka-stream

Inverse of `Flow.batch` in akka streams


Is there an inverse to Flow.batch

I want the signature of the method to be Flow[Vector[T],T,NotUsed]

It should unwrap a Vector and emit every element of the Vector downstream as a single element.


Solution

  • As Levi said in a comment, the answer is mapConcat. As the docs say this operator "transform each element into zero or more elements that are individually passed downstream. This can be used to flatten collections into individual stream elements."

    Also see flatmapConcat if you want to produce a source rather than an iterable.