Skip to content

Instantly share code, notes, and snippets.

@jstultz
Created March 2, 2015 03:45
Show Gist options
  • Save jstultz/65636f681b3e4c5d798d to your computer and use it in GitHub Desktop.
Save jstultz/65636f681b3e4c5d798d to your computer and use it in GitHub Desktop.
def toScalaFuture[A](twitterFuture: Future[A]): ScalaFuture[A] = {
val promise = ScalaPromise[A]()
twitterFuture.respond {
case Return(a) => promise.success(a)
case Throw(e) => promise.failure(e)
}
promise.future
}
def fromScalaFuture[A](scalaFuture: ScalaFuture[A])(implicit executor: ExecutionContext): Future[A] = {
val promise = Promise[A]()
scalaFuture.onComplete {
case ScalaSuccess(a) => promise.setValue(a)
case ScalaFailure(e) => promise.setException(e)
}
promise
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment