/
PromisingStuff.scala
41 lines (37 loc) · 1.15 KB
/
PromisingStuff.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package code.snippet
import xml.NodeSeq
import net.liftweb._
import http._
import js.JE.JsRaw
import js.JsCmds.Script
/**
* Created with IntelliJ IDEA.
* User: dpp
* Date: 3/26/13
* Time: 3:15 PM
* To change this template use File | Settings | File Templates.
*/
object PromisingStuff {
def render: NodeSeq =
(for {
sess <- S.session
} yield Script(JsRaw("var myFuncs = "+sess.buildRoundtrip(List(
"thing" -> thing _)).toJsCmd).cmd)) openOr NodeSeq.Empty
def thing(s: String): Stream[String] = {
var x = 0
(s + x) #:: {Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
{Thread.sleep(1000); x += 1; s + x} #::
Stream.empty[String]
}
}