All futures may be successful eventually (and some may fail), but we want the first successful one. And want to represent that result as a future. This future will fail if all the futures in the list fail.
As indicated the documentation, Future.firstCompletedOf
is provided.
import scala.concurrent.{ExecutionnContext, Future }
def foo[T](f: => Seq[Future[T]])(implicit ec: ExecutionContext): Future[T] =
Future.firstCompletedOf(f)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With