I have a generated java interface containing a method:
public Future> getCustomersAsync(AsyncHandler asyncHandler);
I w
Starting Scala 2.13
, the standard library includes scala.jdk.FutureConverters which provides Scala to Java Future
conversions (and vice versa):
import scala.jdk.FutureConverters._
// val scalaFuture: scala.concurrent.Future[Int] = Future.successful(42)
scalaFuture.asJava
// java.util.concurrent.CompletionStage[Int] =
Note for Java users, you'd rather use FutureConverters
the explicit way:
import scala.jdk.javaapi.FutureConverters;
// val scalaFuture: scala.concurrent.Future[Int] = Future.successful(42)
FutureConverters.asJava(scalaFuture);
// java.util.concurrent.CompletionStage[Int] =