title: How to Inject() into a class with constructor parameters?
body: <p>I have a <code>WebSocket</code> controller which creates per connection actor handler:</p>
  
  <pre><code>class WebSocketController @Inject()(cc: ControllerComponents)(implicit exc: ExecutionContext) {
    def socket: WebSocket = WebSocket.accept[JsValue, JsValue] { request =&gt;
      ActorFlow.actorRef { out =&gt; // Flow that is handled by an actor from 'out' ref
        WebSocketActor.props(out) // Create an actor for new connected WebSocket
      }
    }
  }
  </code></pre>
  
  <p>And inside the actor handler I need to work with <code>ReactiveMongo</code>:</p>
  
  <pre><code>trait ModelDAO extends MongoController with ReactiveMongoComponents { 
    val collectionName: String
    ...
  }
  class UsersCollection @Inject()(val cc: ControllerComponents,
                                  val reactiveMongoApi: ReactiveMongoApi,
                                  val executionContext: ExecutionContext,
                                  val materializer: Materializer)
    extends AbstractController(cc) with ModelDAO {
    val collectionName: String = "users"
  }
  </code></pre>
  
  <p>So, the usual way is to @Inject() <code>UsersCollection</code> in the target class. But I can't do something like:</p>
  
  <pre><code>class WebSocketActor @Inject()(out: ActorRef, users: UsersCollection) extends Actor { ... }
  </code></pre>
  
  <p>Because instances of actor creates inside <code>WebSocketActor</code> companion object:</p>
  
  <pre><code>object WebSocketActor {
    def props(out: ActorRef) = Props(new WebSocketActor(out))
  }
  </code></pre>
  
  <p>How do I use <code>UsersCollection</code> inside the <code>WebSocketActor</code>?</p>