Doc example of Streams watch operator, #25468 (#28752)

This commit is contained in:
Patrik Nordwall 2020-03-26 18:00:58 +01:00 committed by GitHub
parent 5605f04cb7
commit 37d87811b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 1 deletions

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2019-2020 Lightbend Inc. <https://www.lightbend.com>
*/
package docs.stream.operators.sourceorflow
import akka.NotUsed
import akka.actor.ActorRef
import akka.stream.WatchedActorTerminatedException
import akka.stream.scaladsl.Flow
object Watch {
def someActor(): ActorRef = ???
def watchExample(): Unit = {
//#watch
val ref: ActorRef = someActor()
val flow: Flow[String, String, NotUsed] =
Flow[String].watch(ref).recover {
case _: WatchedActorTerminatedException => s"$ref terminated"
}
//#watch
}
}