Thanks, Andrew! This was super helpful to me!

Sorry for the newbie question, but why do we define a companion object for 
MainActor, and create the props that way? What benefit does this give us?

On Wednesday, 26 November 2014 01:23:40 UTC+11, 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