coroutine.lua 371 B

12345678910111213141516171819
  1. local Rx = require 'rx'
  2. -- Cheer someone on using functional reactive programming
  3. local observable = Rx.Observable.fromCoroutine(function()
  4. for i = 2, 8, 2 do
  5. coroutine.yield(i)
  6. end
  7. return 'who do we appreciate'
  8. end)
  9. observable
  10. :map(function(value) return value .. '!' end)
  11. :subscribe(print)
  12. repeat
  13. Rx.scheduler:update()
  14. until Rx.scheduler:isEmpty()