Skip to content

Instantly share code, notes, and snippets.

@nvivo
Created April 23, 2015 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvivo/8192f527326af508e6ba to your computer and use it in GitHub Desktop.
Save nvivo/8192f527326af508e6ba to your computer and use it in GitHub Desktop.
// both actors require dependencies that can be fulfilled by DI
// but you can't do this:
var system = ActorSystem.Create("App");
var actor = system.ActorOf<SomeActor>();
class ActorA : ReceiveActor {
public SomeActor(IDependency dependency) { ... }
var child = context.ActorOf<ActorB>();
}
class ActorB : ReceiveActor {
public SomeActor(IDependency dependency) { ... }
}
// instead you must code in two different ways:
var propsResolver = new SomeDIPropsResolver();
var props = propsResolver.Resolve<ActorA>();
var actor = system.ActorOf(props);
// and inside of the actor you must do
var child = context.DI().ActorOf<ActorB>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment