##MixedTweets
We will see how to mix 2 twitter searches and push the results to the browser in real time.
First, checkout this mini project
To try it, you need to install Play 2.0
###Controller
##MixedTweets
We will see how to mix 2 twitter searches and push the results to the browser in real time.
First, checkout this mini project
To try it, you need to install Play 2.0
###Controller
#Play2 : Les Iteratees expliqués aux humains... francophones!
Disclaimer : Ce qui suit est la traduction d'un article anglophone paru sur le blog mandubian.com
Vous pouvez retrouver l'article original ici
Vous avez probablement remarqué une nouvelle fonctionnalité intrigante de Play2 nommée Iteratee
(ainsi que ses compagnons Enumerators
et Enumeratee
).
Le but de cet article est d'essayer de rendre le concept d'Iteratee compréhensible pour le plus grand nombre avec des arguments simples, en évitant l'approche mathématique / fonctionnelle.
Cet article ne prétend pas tout expliquer à propos des Iteratee / Enumerator / Enumeratee mais traite plutôt les idées qui se cachent derrière.
"For comprehension" is a another syntaxe to use map
, flatMap
and withFilter
(or filter) methods.
yield
keyword is used to aggregate values in the resulting structure.
This composition can be used on any type implementing this methods, like List
, Option
, Future
...
import java.util.Arrays; | |
public class Lambda { | |
public static void main (String[] args){ | |
Arrays.asList("aaa", "bbb", "ccc", "abb").stream() | |
.filter((String w) -> w.startsWith("a")) | |
.forEach(w -> System.out.println(w)); | |
} | |
} |
//val xmlNode = xml.XML.loadFile("xxx") | |
val xmlNode = | |
<persons> | |
<person age="30"> | |
<name>bob</name> | |
</person> | |
<person age="40"> | |
<name>joe</name> | |
</person> |
val f: Future[Int] = Future { | |
if(math.random < 0.5) 1 else throw new Exception("Oh no") | |
} recover { | |
case ex:Exception => { | |
println(ex.getMessage) | |
-1 | |
} | |
} | |
f map println |