FutureUtils

Utilities for Scala's standard concurrent.Future.

class Object
trait Matchable
class Any

Type members

Classlikes

object extensions

Provides extension methods for Future.

Provides extension methods for Future.

Inherited classlikes

final implicit class Java8Extensions[F <: (Future), A](val source: F[A])

Extension methods specific for Java 8 and up.

Extension methods specific for Java 8 and up.

Inherited from:
FutureUtilsForPlatform

Value members

Concrete methods

def delayedResult[A](delay: FiniteDuration)(result: => A)(implicit s: Scheduler): Future[A]

Creates a future that completes with the specified result, but only after the specified delay.

Creates a future that completes with the specified result, but only after the specified delay.

def dematerialize[A](source: Future[Try[A]])(implicit ec: ExecutionContext): Future[A]

Utility that transforms a Future[Try[A]] into a Future[A], hiding errors, being the opposite of materialize.

Utility that transforms a Future[Try[A]] into a Future[A], hiding errors, being the opposite of materialize.

def materialize[A](source: Future[A])(implicit ec: ExecutionContext): Future[Try[A]]

Utility that lifts a Future[A] into a Future[Try[A]], exposing error explicitly.

Utility that lifts a Future[A] into a Future[Try[A]], exposing error explicitly.

def timeout[A](source: Future[A], atMost: FiniteDuration)(implicit s: Scheduler): Future[A]

Utility that returns a new Future that either completes with the original Future's result or with a TimeoutException in case the maximum wait time was exceeded.

Utility that returns a new Future that either completes with the original Future's result or with a TimeoutException in case the maximum wait time was exceeded.

Value parameters:
atMost

specifies the maximum wait time until the future is terminated with a TimeoutException

s

is the Scheduler, needed for completing our internal promise

Returns:

a new future that will either complete with the result of our source or fail in case the timeout is reached.

def timeoutTo[A](source: Future[A], atMost: FiniteDuration, fallback: => Future[A])(implicit s: Scheduler): Future[A]

Utility that returns a new Future that either completes with the original Future's result or after the timeout specified by atMost it tries to complete with the given fallback. Whatever Future finishes first after the timeout, will win.

Utility that returns a new Future that either completes with the original Future's result or after the timeout specified by atMost it tries to complete with the given fallback. Whatever Future finishes first after the timeout, will win.

Value parameters:
atMost

specifies the maximum wait time until the future is terminated with a TimeoutException

fallback

the fallback future that gets triggered after timeout

s

is the Scheduler, needed for completing our internal promise

Returns:

a new future that will either complete with the result of our source or with the fallback in case the timeout is reached

def transform[A, B](source: Future[A], f: Try[A] => Try[B])(implicit ec: ExecutionContext): Future[B]

Given a mapping functions that operates on successful results as well as errors, transforms the source by applying it.

Given a mapping functions that operates on successful results as well as errors, transforms the source by applying it.

Similar to Future.transform from Scala 2.12.

def transformWith[A, B](source: Future[A], f: Try[A] => Future[B])(implicit ec: ExecutionContext): Future[B]

Given a mapping functions that operates on successful results as well as errors, transforms the source by applying it.

Given a mapping functions that operates on successful results as well as errors, transforms the source by applying it.

Similar to Future.transformWith from Scala 2.12.

Inherited methods

def fromJavaCompletable[A](cfa: CompletableFuture[A])(implicit ec: ExecutionContext): Future[A]

Convert CancelableFuture to Java CompletableFuture

Convert CancelableFuture to Java CompletableFuture

Inherited from:
FutureUtilsForPlatform
def toJavaCompletable[A](source: Future[A])(implicit ec: ExecutionContext): CompletableFuture[A]

Convert any Scala Future to Java's CompletableFuture

Convert any Scala Future to Java's CompletableFuture

Inherited from:
FutureUtilsForPlatform

Implicits

Inherited implicits

final implicit def Java8Extensions[F <: (Future), A](source: F[A]): Java8Extensions[F, A]

Extension methods specific for Java 8 and up.

Extension methods specific for Java 8 and up.

Inherited from:
FutureUtilsForPlatform