|
@@ -1,7 +1,8 @@
|
|
local Rx = require 'rx'
|
|
local Rx = require 'rx'
|
|
|
|
|
|
--- Observable created from a coroutine.
|
|
|
|
-local cheer = coroutine.create(function()
|
|
|
|
|
|
+-- Cheer someone on using functional reactive programming
|
|
|
|
+
|
|
|
|
+local observable = Rx.Observable.fromCoroutine(function()
|
|
for i = 2, 8, 2 do
|
|
for i = 2, 8, 2 do
|
|
coroutine.yield(i)
|
|
coroutine.yield(i)
|
|
end
|
|
end
|
|
@@ -9,7 +10,9 @@ local cheer = coroutine.create(function()
|
|
return 'who do we appreciate'
|
|
return 'who do we appreciate'
|
|
end)
|
|
end)
|
|
|
|
|
|
-Rx.Observable.fromCoroutine(cheer):dump('cheer')
|
|
|
|
|
|
+observable
|
|
|
|
+ :map(function(value) return value .. '!' end)
|
|
|
|
+ :subscribe(print)
|
|
|
|
|
|
repeat
|
|
repeat
|
|
Rx.scheduler:update()
|
|
Rx.scheduler:update()
|