I do the same for DI. 

Akka Testkit use this constructor DI mechanism for it's proposed unit test 
approach. 

I've tried with ScalDI, Spring for DI, it works on the implementation side, 
but not working with Akka unit test in terms of using Akka TestKit. Plus, 
introducing a DI framework in AKKA is expensive, and sometimes complicated. 
So I would stick with constructor DI. 



On Tuesday, November 25, 2014 2:23:40 PM UTC, Andrew James Ramirez wrote:
>
> Hi,
>
> What is the best way to do this? Currently what I'm doing is 
>
> class MainActor(Dependency1:ActorRef, Dependency2:ActorRef) = {
>  def receive ={
>      case TestMessage =>
>         Dependency1 ! "Test"
>  }
>
> }
>
> object MainActor{
>   def props(Dependency1:ActorRef, Dependency2:ActorRef) = Props(classOf[
> MainActor], Dependency1, Dependency2)
> }
>
>
>
>
> val dependency1 =  system.actorOf(Dependency1.props())
> val dependency2 =  system.actorOf(Dependency2.props())
>
> val mainActor =  system.actorOf(MainActor.props(dependency1, dependency2))
>
> mainActor ! "TestMessage"
>
>
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to