Introducing watching for completion earlier
So we can terminate the ActorSystem
This commit is contained in:
parent
952fa34c70
commit
18eee18b8c
5 changed files with 71 additions and 36 deletions
|
|
@ -15,6 +15,10 @@ If you want to execute the code samples while you read through the quick start g
|
|||
|
||||
.. includecode:: ../code/docs/stream/QuickStartDocSpec.scala#other-imports
|
||||
|
||||
And an object to hold your code, for example:
|
||||
|
||||
.. includecode:: ../code/docs/stream/QuickStartDocSpec.scala#main-app
|
||||
|
||||
Now we will start with a rather simple source, emitting the integers 1 to 100:
|
||||
|
||||
.. includecode:: ../code/docs/stream/QuickStartDocSpec.scala#create-source
|
||||
|
|
@ -38,6 +42,12 @@ setup to an Actor that runs it. This activation is signaled by having “run”
|
|||
part of the method name; there are other methods that run Akka Streams, and
|
||||
they all follow this pattern.
|
||||
|
||||
When running this source in a :class:`scala.App` you might notice it does not
|
||||
terminate, because the :class:`ActorSystem` is never terminated. Luckily
|
||||
``runForeach`` returns a :class:`Future[Done]` which resolves when the stream finishes:
|
||||
|
||||
.. includecode:: ../code/docs/stream/QuickStartDocSpec.scala#run-source-and-terminate
|
||||
|
||||
You may wonder where the Actor gets created that runs the stream, and you are
|
||||
probably also asking yourself what this ``materializer`` means. In order to get
|
||||
this value we first need to create an Actor system:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue