Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 694 Bytes

timer.md

File metadata and controls

40 lines (31 loc) · 694 Bytes

API Reference - uv.timer

timer.set(timeout, callback)

Schedule a function to be called once in the future. Returns immediately.

timer.set(5000, function()
  print('Ding!')
end)
print('Waiting 5 seconds...')
loop.run()
print('The timer dinged.')

timer.every(timeout, callback)

Schedule a function to be called every timeout milliseconds. Returns immediately.

timer.every(1000, function(t)
  print('Tick...')
  if we_are_done then
    t:stop()
  end
end)
loop.run()

timer.sleep(timeout, callback)

Yield the current coroutine for timeout milliseconds.

print('Going to sleep...')
timer.sleep(5000)
print('Woke up')