Document how to convert Twitter futures to Akka/Scala futures
Twitter Future -> Akka 2.0.x Futures
Twitter Future -> Scala 2.10 Futures
Drew Kutcharian drew@venarc.com via googlegroups.com
12:10 PM (1 hour ago)
to akka-user
Thanks Derek. I'll give this a try.
On Jan 12, 2013, at 6:47 PM, Derek Williams <derek@fyrie.net> wrote:
I'm not really familiar with Twitter's library, but should be able to do something like this:
import scala.concurrent.{Future, Promise}
import com.twitter.util.{Future => TwitterFuture, Throw, Return}
def fromTwitter[A](twitterFuture: TwitterFuture[A]): Future[A] = {
val promise = Promise[A]()
twitterFuture respond {
case Return(a) => promise success a
case Throw(e) => promise failure e
}
promise.future
}
Twitter Future -> Scala 2.10 Futures
Drew Kutcharian drew@venarc.com via googlegroups.com
12:10 PM (1 hour ago)
to akka-user
Thanks Derek. I'll give this a try.
On Jan 12, 2013, at 6:47 PM, Derek Williams <derek@fyrie.net> wrote:
I'm not really familiar with Twitter's library, but should be able to do something like this:
import scala.concurrent.{Future, Promise}
import com.twitter.util.{Future => TwitterFuture, Throw, Return}
def fromTwitter[A](twitterFuture: TwitterFuture[A]): Future[A] = {
val promise = Promise[A]()
twitterFuture respond {
case Return(a) => promise success a
case Throw(e) => promise failure e
}
promise.future
}
Leave a comment
It's a blog post and not a feature or bug. We don't want to add a dependency on Twitter just to compile an example. Please write a blog post and we'll gladly publish it on letitcrash.com!
Cheers,
√
Cheers,
√