When I do future or apply methods such as onSuccess and map , I can specify ExecutionContext for them.
For example,
val f = future { // code } executionContext f.map(someFunction)(executionContext) f onSuccess { // code } executionContext
However, if I use for-comprehension of future, how can I specify an ExecutionContext for the yield part?
for { f <- future1 g <- future2 } yield { // code to be executed after future1 onSuccess and future2 onSuccess // What ExecutionContext runs this code? } // (executionContext) here does not work
And what does the ExecutionContext run the code in the lesson if not specified?
<h / "> EDIT
OK Thanks to the answers, I found something.
Unless I define or import an implicit ExecutionContext (for example, Implicits.global ), Understanding does not compile. This means that an implicit ExecutionContext is used for understanding.
Then, how can I use for-comprehension without an implicit ExecutionContext, i.e. how to specify?
scala future for-comprehension
Naetmul
source share