Handling streams reactively
Whenever you need to consume and transform streams of data in web applications, such as watching stock updates or monitoring log activities on a service, you need mechanisms to manipulate chunks of data that can be pushed from a server to a browser, for instance, using Comet (http://en.wikipedia.org/wiki/Comet_(programming)) or WebSocket (http://en.wikipedia.org/wiki/WebSocket) technologies. The Iteratee
pattern available within the Play framework is such a mechanism. It was borrowed from the Haskell functional language initially.
Understanding Iteratees in Play
An Iteratee
construct aims at providing a composable and nonblocking way of handling streams produced by its counterpart called Enumerator
.
Let's launch a Scala REPL to explore the Iteratee
/Enumerator
constructs in more detail. To create a new play project as we have done several times before, notably in Chapter 5, Getting Started with the Play Framework, use the following command:
> play new ch9samples...