有没有在lua中执行`setTimeout`的库?

时间:2018-09-11 14:23:22

标签: timer lua dependencies

我尝试使用RxLua的TimeoutScheduler安排任务。但这导致lua抱怨没有这样的模块。

-- minimalexample.lua
scheduler = require('rx').TimeoutScheduler.create()
scheduler:schedule(function() return, 1000)

结果:

lua: ./rx.lua:1913: module 'timer' not found:
...
stack traceback:
  [C]: in function 'require'
  ./rx.lua:1913: in method 'schedule'
  timedtest.lua:7: in main chunk
  [C]: in ?

我在网上搜索无济于事。也将an issue张贴在项目页面上。

那里需要什么模块?我在做错什么吗?

2 个答案:

答案 0 :(得分:0)

filter=<the date field name> ge 2018-01-01T00:00:00-08:00 and <the date field name> le 2018-01-01T00:00:00-08:00 模块的维护者对此很有反应:

https://github.com/bjornbytes/RxLua/issues/29#issuecomment-420311383

这取决于RxLua

答案 1 :(得分:0)

标准Lua中不存在waitsleep函数。 Luvit有一个timer模块,可用于实现相同的功能。

local timer = require('timer')

timer.setTimeout(delay, callback, ...)-在经过一定延迟(以毫秒为单位)后执行一次回调。 varargs在执行时传递给回调。