Skip to content

Instantly share code, notes, and snippets.

@landonf
Created February 16, 2014 20:08
Show Gist options
  • Save landonf/9039927 to your computer and use it in GitHub Desktop.
Save landonf/9039927 to your computer and use it in GitHub Desktop.
Proposed Future API
/**
* A future is a possibly asynchronous, functional computation producing a value of type `T`, or a failure
* of type `E`.
*/
trait Future[+E, +T] {
def swap: Future[T, E]
def foreach[U] (f: T => U): Future[E, T]
def getOrElse[T1 >: T] (default: => T1): Future[E, T1]
def flatMap[E1, T1] (f: (T) => Future[E1, T1]): Future[E1, T1]
def map[T1] (f: (T) => T1): Future[E, T1]
def leftMap[E1] (f: E => E1): Future[E1, T]
def filter[E1 >: E] (predicate: T => Boolean) (implicit identity: ZeroIdentity[E1]): Result[E1, T]
/**
* Evaluate this future to completion, passing the result to `f`.
*
* @param f The callback function to which the result will be supplied.
*/
def subscribe[U] (f: (Result[E, T]) => U): Unit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment