-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
27 lines (24 loc) · 944 Bytes
/
test.lua
File metadata and controls
27 lines (24 loc) · 944 Bytes
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
class = class or require("Class")
Observable = Observable or require("Observable")
EventStream = EventStream or require("EventStream")
History = History or require("History")
local numbers = EventStream.new():log("Number")
local sum = numbers:scan(0, function(s,n) return s+n end):log("Sum")
_.eachi(_.range(10), function(value)
numbers:push(value)
end)
numbers:close()
local channelA = History.new("Hello Channel A!")
local channelB = History.new("Hello Channel B!")
local channelC = History.new("Hello Channel C!")
local channel_switch = EventStream.new()
local channel_all = channel_switch:flatten():log("Channel All:")
local channel_latest = channel_switch:flatten_latest():log("Channel Latest:")
local channel_first = channel_switch:flatten_first():log("Channel First:")
channel_switch:push(channelA)
channel_switch:push(channelB)
channel_switch:push(channelC)
channelA:close()
channelB:close()
channelC:close()
channel_switch:close()