Skip to main content

porla_timers

Create various types of timers, such as one-shot, intervals and cron schedules.

Exports​

cron(expr: string, callback: function): PoCancellable​

v0.42.0

Sets up a cron schedule and returns a cancellable that can be used to cancel the cron schedule.

expr takes six fields; sec min hour dom month dow (croncpp syntax). An invalid expression raises.

Runs in the server's local time.

Example​

local timers = require("porla_timers")

timers.cron("*/5 * * * * ?", function()
print("I print every 5 seconds")
end)

epoch(): number​

The current Unix time in milliseconds.

interval(ms: number, callback: function): PoCancellable​

v0.42.0

Sets up a recurring interval that fires every N milliseconds.

Example​

local timers = require("porla_timers")

timers.interval(3000, function()
print("I print every 3 seconds")
end)

timeout(ms: number, callback: function): PoCancellable​

v0.42.0

Sets up a one-shot timeout that fires once after N milliseconds.

Example​

local timers = require("porla_timers")

timers.timeout(300, function()
print("I fire once after 300 milliseconds")
end)