Skip to content

Instantly share code, notes, and snippets.

@mathieuancelin
Created September 5, 2013 17:36
Show Gist options
  • Save mathieuancelin/6453456 to your computer and use it in GitHub Desktop.
Save mathieuancelin/6453456 to your computer and use it in GitHub Desktop.
object Streams extends Controller {
def stream = Action {
val operations: Enumerator[JsValue] = Enumerator.generateM[JsValue] {
Promise.timeout(
Some( Json.obj(
"id" -> UUID.randomUUID().toString(),
"amount" -> Random.nextInt(1000),
"access" -> if (Random.nextBoolean) "public" else "private"
) ),
500
)
}
Ok.chunked( operations )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment