Created
October 5, 2012 20:55
-
-
Save diegovar/3842347 to your computer and use it in GitHub Desktop.
Play promise to Akka future
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
/** | |
* This is a helper function because there is no existing conversion from Play promise to Akka future in Play. | |
* @param promise | |
* @tparam A | |
* @return | |
*/ | |
implicit def toAkkaFuture[A](promise: PlayPromise[A]): Future[A] = { | |
val p = akka.dispatch.Promise[A]() | |
promise extend1 { | |
case Redeemed(value) => p success value | |
case Thrown(exn) => p failure exn | |
} | |
p.future | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment