How to understand `Iteratee` in play2?

2019-03-19 15:31发布

There's a package play.api.libs.iteratee in play2, which has a big object Iteratee which has more than 1000 lines.

Why play2 need such a big object and how to understand it?

2条回答
萌系小妹纸
3楼-- · 2019-03-19 16:23

I just wrote an article trying to explain the concepts of Iteratees provided by Play2 for those who try to discover them.

http://mandubian.com/2012/08/27/understanding-play2-iteratees-for-normal-humans/

Here is the conclusion of the article because it appears I must put essential parts to answer your question. But my article is a whole and your question is also quite large...

Anyway, why should I use Iteratee / Enumerator / Enumeratee ?

I want to tell you that Iteratee / Enumerator / Enumeratee is not a funny tool for people found of functional constructions. They are useful in many domains and once you will understand how they work, I can promise you that you will begin to use it more and more.

Modern web applications are not only dynamically generated pages anymore. Now you manipulate flows of data coming from different sources, in different formats, with different availability timing. You may have to serve huge amount of data to huge number of clients and to work in distributed environments.

Iteratee are made for those cases because there are safe, immutable and very good to deal with data flows in realtime. Let’s tell the buzzword you can see more & more “Realtime WebApp” and Iteratee is associated to that ;)

查看更多
登录 后发表回答