title: Composing actors
body: <p>I've implemented a Listenable/Listener trait that can be added to Actors. I'm wondering if it's possible to attach this style of trait to an actor without it having to explicitly call the <em>listenerHandler</em> method?</p>
  
  <p>Also I was expecting to find this functionality in the Akka library. Am I missing something or is there some reason that Akka would not not include this?</p>
  
  <pre><code>trait Listenable { this: Actor =&gt;
      private var listeners: List[Actor] = Nil
  
      protected def listenerHandler: PartialFunction[Any, Unit] = {
          case AddListener(who) =&gt; listeners = who :: listeners
      }
  
      protected def notifyListeners(event: Any) = {
          listeners.foreach(_.send(event))
      }
  }
  
  class SomeActor extends Actor with Listenable
  {
      def receive = listenerHandler orElse {
          case Start =&gt; notifyListeners(Started())
          case Stop =&gt; notifyListeners(Stopped())
      }
  }
  </code></pre>