On Friday, 22 March 2013 15:37:45 UTC+1, Nabloom wrote:
Hi,
don't know if it's the most efficient way but you can :
- turn Seq[Future[X]] to Seq[Enumerator[X]] using Enumerator.generateM
- turn Seq[Enumerator[X]] to Enumerator[X] using Enumerator.interleave
Thanks. I got the following to work:
def toEnumerator(seqFutureX: Seq[Future[X]]) = new Enumerator[X] {
def apply[A](i: Iteratee[X, A]): Future[Iteratee[X, A]] = {
Future.sequence(seqFutureX).flatMap { seqX: Seq[X] =>
seqX.foldRight(Future.successful(i)) {
case (x, i) => i.flatMap(_.feed(Input.El(x)))
}
}
}
}
and posted it on StackOverflow...