title: How do I pass a callback function to an akka actor constructor when using Context.actorOf?
body: <p>I want to pass a callback to an akka actor in its constructor: </p>
  
  <pre><code>object FSMActorWithCallback {
    type Tracer = (Int, NodeState, NodeData, ActorRef, Any) =&gt; Unit
  }
  
  class FSMActorWithCallback(tracerCallback: FSMActorWithCallback.Tracer) extends FSMAwesomeActor
    // method is called each FSM Event so we can record current state and next message 
    override def trace(state: NodeState, data: NodeData, sender: ActorRef, msg: Any) : Unit = {
      // different tracing callback for different test rigs such as unit tests or integration tests
      tracerCallback(nodeUniqueId, state, data, sender, msg)
    }
  }
  </code></pre>
  
  <p>This would let me define raw actor using <code>new</code> but I need to use the <code>actorOf</code> factory method to have the actor correctly hooked into the system: </p>
  
  <pre><code>class Supervisor extends Actor {
  
    def outputStateTrace(state: NodeState, data: NodeData, sender: ActorRef, msg: Any): Unit = { 
      /*actually make a binary log for analysis of complex failures*/
    }
  
    // COMPILE ERROR "follow this method with _ if you wan to treat it as a partially applied function" 
    var child = contact.actorOf(Props(classOf[FSMActorWithCallback], outputStateTracer) 
  
    // seems to work fine but not what i need
    val childRaw = new FSMActorWithCallback(tracer) 
  
  }
  </code></pre>
  
  <p>The actual construction of the actor needs to be by the factory method shown but I cannot figure out how to pass a callback through the factory method. </p>