Hi all,

The section here: 
http://doc.akka.io/docs/akka/2.4.4/scala/testing.html#Testing_parent-child_relationships

Has some good advice on doing child creation via dep injection so I could 
pass in mock children during testing. That's great, but the example is a 
bit of a toy because you can't pass a name or non-default properties, which 
makes it pretty useless for anything real-world.

I ended up doing this:

type ActorMaker = (ActorRefFactory, Props, String) => ActorRef
private def childMaker(f: ActorRefFactory, p: Props, actorName: String) = {
  f.actorOf(p, actorName)
}


class MyClass(...stuff...    
              childActorFactory: ActorMaker = CLFSM.childMaker)


And then calling it like

childActorFactory(context,
                  SomeChild.props(props, go, here),
                  "SomeName")


That's fine, I guess, but seems a little uglier than necessary.

I tried defining childMaker with an implicit ActorRefFactory, but then the 
class can't compile because it's trying to find the ActorRefFactory 
"outside" of the class, since that is where default values are evaluated.

Is there a more clever way I can do this without having to pass "context" 
every time inside my class? Is there a better way I can do it entirely?

Thanks!

Spencer

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to