=doc: take and takeWhile (#28078)

* Switch java examples to pass in actorsystem instead of materializer
This commit is contained in:
Christopher Batey 2019-11-25 09:50:41 +00:00 committed by Patrik Nordwall
parent 0384baa53e
commit 1b68951f86
5 changed files with 93 additions and 17 deletions

View file

@ -0,0 +1,21 @@
/*
* Copyright (C) 2019 Lightbend Inc. <https://www.lightbend.com>
*/
package docs.stream.operators.sourceorflow
object Take {
def takeExample(): Unit = {
import akka.actor.ActorSystem
import akka.stream.scaladsl.Source
implicit val system: ActorSystem = ActorSystem()
// #take
Source(1 to 5).take(3).runForeach(println)
// 1
// 2
// 3
// #take
}
}

View file

@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 Lightbend Inc. <https://www.lightbend.com>
*/
package docs.stream.operators.sourceorflow
object TakeWhile {
def takeWhileExample(): Unit = {
import akka.actor.ActorSystem
import akka.stream.scaladsl.Source
implicit val system: ActorSystem = ActorSystem()
// #take-while
Source(1 to 10).takeWhile(_ < 3).runForeach(println)
// 1
// 2
// #take-while
}
}