It seems like i am able to inject Services or Akka Actors without the use of Module. May i know what is the purpose of Module then?
class Hello(implicit inj:Injector) extends Controller with AkkaInjectable {
val greetingService = inject[GreetingService]
implicit val system = inject [ActorSystem]
val greetingActor = injectActorRef[greetingActor]
def greet(person:Person) = Action {
Ok(greetingService.greet(person.name))
}
}
Even without the below it works just fine
class MainModule extends Module {
binding to new GreetingService
bind [ActorSystem] to ActorSystem("ScaldiAkkaExample") destroyWith (_.terminate())
binding toProvider new StatisticsProvider
}
Module basically instantiates the services and when you inject them to your controllers, all controllers share the same instance (which is what we want). Without declaring the bindings in module you will have a new instance of service in every controller (which is not what we want).
However in Akka its the opposite
Quote from scaldi