coroutine.lua 306 B

12345678910111213141516
  1. local Rx = require 'rx'
  2. -- Observable created from a coroutine.
  3. local cheer = coroutine.create(function()
  4. for i = 2, 8, 2 do
  5. coroutine.yield(i)
  6. end
  7. return 'who do we appreciate'
  8. end)
  9. Rx.Observable.fromCoroutine(cheer):dump('cheer')
  10. repeat
  11. Rx.scheduler:update()
  12. until Rx.scheduler:isEmpty()