Posting my owner discovery for future readers/searchers, especially since 
it's so simple :)

The short answer: splitWhen(ign => true)

The code is probably not idiomatic, being my second short foray into scala. 
It does compile and run on my setup. Any general thoughts/improvements are 
appreciated :)

package spss

import scala.concurrent._
import scala.concurrent.duration._

import akka.actor.{ ActorSystem }
import akka.stream._
import akka.stream.scaladsl._

object BatchSplitWhen {
  val system = ActorSystem.create("batch2")
  implicit val materializer = ActorMaterializer.create(system)

  def main(args: Array[String]): Unit = {
    val batchesStr = s"a word or two\nseparated by newlines\nmakes for a 
simple\nstreaming batch test."
    val batches = 
Source(batchesStr.split("\n").to[collection.immutable.Seq])
*    val substreams = batches.splitWhen(s => true)*
    val toWords = substreams.mapConcat(_.split(" 
").to[collection.immutable.Seq])
    val toUpper = toWords.map(_.toUpperCase)
    val toLine = toUpper.reduce(_ + "-" + _)
*    val toLines = toLine.mergeSubstreams.runFold("")(_ + "\n" + _)*

    val res = Await.result(toLines, 5 seconds)
    println(res)
    system.terminate
  }
}

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to