February 2018
Intermediate to advanced
552 pages
13h 46m
English
Let's understand the Scala API for a Promise. Scala has a trait for a Promise in the scala.concurrent package, which is as follows:
trait Promise[T] extends AnyRef
Scala Promise trait has the following important and frequently used functions:
trait Promise[T]{
def success(value: T) : this.type
def failure(cause: Throwabale): this.type
def future: Future[T]
}
Its companion object is defined as shown here:
object Promise[T] {
def apply[T](): Promise[T]
}
Read now
Unlock full access