RxLua icon indicating copy to clipboard operation
RxLua copied to clipboard

module 'timer' not found when using `TimeoutScheduler:schedule`

Open xtofl opened this issue 6 years ago • 3 comments

TimeoutScheduler depends on 'a' timer module, which isn't mentioned in any dependency.

Reproduce:

luarocks install rxlua

lua
> rx = require('rx')
> s = rx.TimeoutScheduler.create()
> s:schedule(function() end, 1000)
lua: ... module 'timer' not found:
	no field package.preload['timer']
	no file '/usr/local/share/lua/5.3/timer.lua'
	no file '/usr/local/share/lua/5.3/timer/init.lua'
...

xtofl avatar Sep 11 '18 13:09 xtofl

The TimeoutScheduler only works when run within luvit. I'm not sure it would be possible to add that as a dependency using luarocks. This is mentioned in the docs, but maybe we could pcall and throw a better error so it's less confusing? Let me know if you have any other ideas

bjornbytes avatar Sep 11 '18 15:09 bjornbytes

We could add it as a lit dependency like this.

bjornbytes avatar Sep 11 '18 15:09 bjornbytes

Thanks! That explains it. I read over it - silly. Shall I add it to the dependencies in the rockspec?

xtofl avatar Sep 12 '18 09:09 xtofl