Slide 33
Slide 33 text
final case class Map[In, Out](f: In ⇒ Out) extends GraphStage[FlowShape[In, Out]]
{
val in = Inlet[In]("Map.in")
val out = Outlet[Out]("Map.out")
override val shape = FlowShape(in, out)
override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
new GraphStageLogic(shape) with InHandler with OutHandler {
override def onPush(): Unit = push(out, f(grab(in)))
override def onPull(): Unit = pull(in)
setHandlers(in, out, this)
}
}
AKKA STREAMS - GRAPHSTAGE API