timer: Add a callback constructor property
Avoids having to keep a local variable just to be able to register the callback.
This commit is contained in:
parent
bd96eacbe2
commit
d8f51a4039
|
@ -105,6 +105,8 @@ local timer_instance_mt = {
|
|||
-- @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.
|
||||
-- @tparam[opt=nil] function args.callback Callback function to connect to the
|
||||
-- "timeout" signal.
|
||||
-- @treturn timer
|
||||
-- @function gears.timer
|
||||
function timer.new(args)
|
||||
|
@ -122,6 +124,10 @@ function timer.new(args)
|
|||
ret:start()
|
||||
end
|
||||
|
||||
if args.callback then
|
||||
ret:connect_signal("timeout", args.callback)
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue