Skip to content

Instantly share code, notes, and snippets.

@alaz
Forked from viktorklang/PostStart.scala
Created March 6, 2011 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alaz/857717 to your computer and use it in GitHub Desktop.
Save alaz/857717 to your computer and use it in GitHub Desktop.
trait PostStart { actor: Actor =>
def postStart: Unit
override def preStart {
super.preStart
actor.become {
case "PostStart" => try { postStart } finally { actor.unbecome }
}
actor.self ! "PostStart"
}
}
/*Usage: class MyActor extends Actor with PostStart {
def postStart = {
...
}
def receive = {
... your usual business stuff goes here ...
}
}*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment