Last active
August 29, 2015 14:06
-
-
Save langley/7bf50e5a86207ba3be4f to your computer and use it in GitHub Desktop.
Play Framework 2.2.x Enumerator Example
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
// Start play, go into the console and copy & paste these lines | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
import scala.language.postfixOps | |
import play.api.libs.iteratee._ | |
import play.api.libs.concurrent.Execution.Implicits._ | |
val enumerateUsers: Enumerator[String] = { | |
Enumerator("Guillaume", "Sadek", "Peter", "Erwan") | |
} | |
val consume = Iteratee.consume[String]() | |
val newIteratee: Future[Iteratee[String,String]] = enumerateUsers(consume) | |
val eventuallyResult: Future[String] = newIteratee.flatMap(i => i.run) | |
eventuallyResult.onSuccess { case x => println(x) } | |
// from https://www.playframework.com/documentation/2.2.x/Enumerators |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment