parent
63ccdeec16
commit
b1df13d4d4
221 changed files with 1528 additions and 1580 deletions
|
|
@ -24,14 +24,14 @@ class Parent extends Actor {
|
|||
var ponged = false
|
||||
|
||||
def receive = {
|
||||
case "pingit" => child ! "ping"
|
||||
case "pong" => ponged = true
|
||||
case "pingit" ⇒ child ! "ping"
|
||||
case "pong" ⇒ ponged = true
|
||||
}
|
||||
}
|
||||
|
||||
class Child extends Actor {
|
||||
def receive = {
|
||||
case "ping" => context.parent ! "pong"
|
||||
case "ping" ⇒ context.parent ! "pong"
|
||||
}
|
||||
}
|
||||
//#test-example
|
||||
|
|
@ -39,7 +39,7 @@ class Child extends Actor {
|
|||
//#test-dependentchild
|
||||
class DependentChild(parent: ActorRef) extends Actor {
|
||||
def receive = {
|
||||
case "ping" => parent ! "pong"
|
||||
case "ping" ⇒ parent ! "pong"
|
||||
}
|
||||
}
|
||||
//#test-dependentchild
|
||||
|
|
@ -50,18 +50,18 @@ class DependentParent(childProps: Props) extends Actor {
|
|||
var ponged = false
|
||||
|
||||
def receive = {
|
||||
case "pingit" => child ! "ping"
|
||||
case "pong" => ponged = true
|
||||
case "pingit" ⇒ child ! "ping"
|
||||
case "pong" ⇒ ponged = true
|
||||
}
|
||||
}
|
||||
|
||||
class GenericDependentParent(childMaker: ActorRefFactory => ActorRef) extends Actor {
|
||||
class GenericDependentParent(childMaker: ActorRefFactory ⇒ ActorRef) extends Actor {
|
||||
val child = childMaker(context)
|
||||
var ponged = false
|
||||
|
||||
def receive = {
|
||||
case "pingit" => child ! "ping"
|
||||
case "pong" => ponged = true
|
||||
case "pingit" ⇒ child ! "ping"
|
||||
case "pong" ⇒ ponged = true
|
||||
}
|
||||
}
|
||||
//#test-dependentparent
|
||||
|
|
@ -72,7 +72,7 @@ class GenericDependentParent(childMaker: ActorRefFactory => ActorRef) extends Ac
|
|||
|
||||
class MockedChild extends Actor {
|
||||
def receive = {
|
||||
case "ping" => sender ! "pong"
|
||||
case "ping" ⇒ sender ! "pong"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ class ParentChildSpec extends WordSpec with Matchers with TestKitBase with Befor
|
|||
"be tested with a child probe" in {
|
||||
val probe = TestProbe()
|
||||
//#child-maker-test
|
||||
val maker = (_: ActorRefFactory) => probe.ref
|
||||
val maker = (_: ActorRefFactory) ⇒ probe.ref
|
||||
val parent = system.actorOf(Props(classOf[GenericDependentParent], maker))
|
||||
//#child-maker-test
|
||||
probe.send(parent, "pingit")
|
||||
|
|
@ -115,7 +115,7 @@ class ParentChildSpec extends WordSpec with Matchers with TestKitBase with Befor
|
|||
|
||||
"demonstrate production version of child creator" in {
|
||||
//#child-maker-prod
|
||||
val maker = (f: ActorRefFactory) => f.actorOf(Props[Child])
|
||||
val maker = (f: ActorRefFactory) ⇒ f.actorOf(Props[Child])
|
||||
val parent = system.actorOf(Props(classOf[GenericDependentParent], maker))
|
||||
//#child-maker-prod
|
||||
}
|
||||
|
|
@ -139,8 +139,8 @@ class ParentChildSpec extends WordSpec with Matchers with TestKitBase with Befor
|
|||
val parent = system.actorOf(Props(new Actor {
|
||||
val child = context.actorOf(Props[Child], "child")
|
||||
def receive = {
|
||||
case x if sender == child => proxy.ref forward x
|
||||
case x => child forward x
|
||||
case x if sender == child ⇒ proxy.ref forward x
|
||||
case x ⇒ child forward x
|
||||
}
|
||||
}))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue