Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I define implicit arguments in the apply method?

Tags:

scala

I would like to define two implicit parameters in the apply method as the following:

object WsGraph {

  def apply(logger: Logger, sink: Sink[Message, Future[Done]])
           (implicit system: ActorSystem, implicit executor: ExecutionContextExecutor) {

  }
}

But the compiler does not allow this. How to do it correctly?

like image 277
softshipper Avatar asked Mar 19 '26 06:03

softshipper


1 Answers

You just need to add one keyword implicit at the beginning of the second argument list and all arguments on it will be implicit:

object WsGraph {      
    def apply(logger: Logger, sink: Sink[Message, Future[Done]])
               (implicit system: ActorSystem, executor: ExecutionContextExecutor) {

    }
}
like image 88
Krzysztof Atłasik Avatar answered Mar 20 '26 20:03

Krzysztof Atłasik