Intercept / Decorate a PartialFunction

Viewed 187

How do I intercept a PartialFunction? e.g. in actors, if I'd like to just print everything that comes into the following receive method before passing it onto the process method:

class MyActor extends Actor {
  def receive : Receive = process
  def process : Receive = {
    case Some(x) => /* do one thing */ ()
    case None => /* do another thing */ ()
    case _ => /* do something else */ ()
  }
}
3 Answers
Related