Skip to content

Instantly share code, notes, and snippets.

@bjarkevad
Created December 3, 2013 17:00
Show Gist options
  • Save bjarkevad/7772903 to your computer and use it in GitHub Desktop.
Save bjarkevad/7772903 to your computer and use it in GitHub Desktop.
continueWith
def continueWith[S](cont: Future[T] => S): Future[S] = {
val p: Promise[S] = Promise()
f.onComplete {
case Failure(f) => p.complete(Failure(f))
case Success(v) => p.completeWith(Future(cont(f)))
}
return p.future
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment