-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathperceive.edh
56 lines (44 loc) · 1.09 KB
/
perceive.edh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
evs = chan
stopSig = chan
go {@
perceive evs { ev } -> {
console.info <| ' 🎐 sth perceived: ' ++ ev
}
# keep this thread running forever
for _ from console.everySeconds(60) do pass
@}
go {@
defer {
console.info <| "I'm really done."
}
perceive stopSig {
nil -> {
console.warn <| ' 🎬 stopping because end-of-stream'
fallthrough
}
{ ev } -> {
console.info <| ' 🎬 stopping because: ' ++ ev
fallthrough
}
break # break from a perceiver terminates the thread
}
for ev from evs do {
console.info <| ' 🎉 sth received: ' ++ ev
}
@}
}
# wait a second
for _ from console.everySeconds( 1 ) do break
evs <- ' 🛎️ ding.ding..'
# stopSig <- "don't do that!"
# wait a second
for _ from console.everySeconds( 1 ) do break
evs <- ' 🍃 chill..chill...'
stopSig <- "that's enough!"
# wait a second
for _ from console.everySeconds( 1 ) do break
evs <- ' ☎️ ling.ling..ling...'
# stopSig <-nil
# wait a second
for _ from console.everySeconds( 1 ) do break