Skip to content

Instantly share code, notes, and snippets.

@arschles
Created May 2, 2013 18:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arschles/5504373 to your computer and use it in GitHub Desktop.
Save arschles/5504373 to your computer and use it in GitHub Desktop.
Converting a Twitter future to a Scala Future
import com.twitter.util.{Future => TwFuture}
import scala.concurrent.{Future => ScFuture, promise => scPromise}
implicit def twFutureToScala[T](twFuture: TwFuture[T]): ScFuture[T] = {
val prom = scPromise[T]
twFuture.onComplete { res: T =>
prom.success(res)
}
twFuture.onFailure { t: Throwable =>
prom.failure(t)
}
prom
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment