=doc: take and takeWhile (#28078)
* Switch java examples to pass in actorsystem instead of materializer
This commit is contained in:
parent
0384baa53e
commit
1b68951f86
5 changed files with 93 additions and 17 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue