Created
April 28, 2014 09:04
-
-
Save srenault/11366199 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
object Utils { | |
import scala.concurrent.duration._ | |
import play.api.libs.concurrent.Promise | |
import play.api.libs.iteratee.{ Enumerator, Iteratee } | |
def sequence[A, B](seq: Seq[A])(f: A => Future[B]): Future[Seq[B]] = { | |
val enumerator = Enumerator[A](seq: _*) | |
val consummer = Iteratee.foldM[A, Seq[B]](Seq.empty[B]) { | |
case (acc, i) => f(i).map(t => t +: acc) | |
} | |
enumerator.run(consummer) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment