Created
December 3, 2013 17:00
-
-
Save bjarkevad/7772903 to your computer and use it in GitHub Desktop.
continueWith
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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