timer: Add an autostart constructor property
This commit is contained in:
parent
2c3aebc19e
commit
bd96eacbe2
|
@ -104,9 +104,11 @@ local timer_instance_mt = {
|
|||
--- Create a new timer object.
|
||||
-- @tparam table args Arguments.
|
||||
-- @tparam number args.timeout Timeout in seconds (e.g. 1.5).
|
||||
-- @tparam[opt=false] boolean args.autostart Automatically start the timer.
|
||||
-- @treturn timer
|
||||
-- @function gears.timer
|
||||
timer.new = function(args)
|
||||
function timer.new(args)
|
||||
args = args or {}
|
||||
local ret = object()
|
||||
|
||||
ret.data = { timeout = 0 }
|
||||
|
@ -116,6 +118,10 @@ timer.new = function(args)
|
|||
ret[k] = v
|
||||
end
|
||||
|
||||
if args.autostart then
|
||||
ret:start()
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue