Skip to content

Instantly share code, notes, and snippets.

@chbatey
Created February 5, 2014 22:34
Show Gist options
  • Select an option

  • Save chbatey/8834715 to your computer and use it in GitHub Desktop.

Select an option

Save chbatey/8834715 to your computer and use it in GitHub Desktop.
Akka: Using a ActorRefFactory to make it easier to test
class ParentActor(childFactory: (ActorRefFactory) => ActorRef) extends Actor {
def receive: Actor.Receive = {
case msg @ _ => {
println(s"Received msg, delegating work to a child actor")
val childActor = childFactory(context)
childActor ! "Go and do something important!"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment