I have two futures. I want to execute them in order. For example:
val ec: ExecutionContextExecutor = ExecutionContext.Implicits.global
val first=Future.successful(...)
val second=Future.successful(...)
When first is completed then second should be executed. The problem is that second should return Future[Object]
not Future[Unit]
so
I can not use completed, andThen
etc. functions
I can not block the process using await
or Thread.sleep(...)
I can not use for loop since execution context is defined like this.
first.flatmap( _=> second)
will not execute in order.
How can I do that?