February 2018
Intermediate to advanced
552 pages
13h 46m
English
The Scala Async object is defined in the scala.async package. It has the following two functions:
object Async { def async[T](body: => T)(implicit execContext: ExecutionContext): Future[T] def await[T](awaitable: Future[T]): T}
The async function is similar to the apply function of the Future object. It takes an asynchronous computation as input and returns a Future object.
The await function takes a future object as input and returns that Future's value. It does not block the underlying thread that executes that computation logic.
An example of the Scala Async API:
name := "scala-async-app" version := "1.0.0" scalaVersion := ...