-
-
Save alaz/857717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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