doc: improve meta info / structure for gears.timer
This commit is contained in:
parent
302e698ba8
commit
47ffb1610c
|
@ -1,3 +1,4 @@
|
||||||
|
--- Timer objects and functions.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
-- @author Uli Schlachter
|
-- @author Uli Schlachter
|
||||||
-- @copyright 2014 Uli Schlachter
|
-- @copyright 2014 Uli Schlachter
|
||||||
|
@ -18,12 +19,12 @@ local object = require("gears.object")
|
||||||
--- Timer objects. This type of object is useful when triggering events repeatedly.
|
--- Timer objects. This type of object is useful when triggering events repeatedly.
|
||||||
-- The timer will emit the "timeout" signal every N seconds, N being the timeout
|
-- The timer will emit the "timeout" signal every N seconds, N being the timeout
|
||||||
-- value.
|
-- value.
|
||||||
-- @field timeout Interval in seconds to emit the timeout signal. Can be any
|
-- @tfield number timeout Interval in seconds to emit the timeout signal.
|
||||||
-- value, including floating point ones (i.e. 1.5 seconds).
|
-- Can be any value, including floating point ones
|
||||||
-- @field started Read-only boolean field indicating if the timer has been
|
-- (e.g. 1.5 seconds).
|
||||||
-- started.
|
-- @tfield boolean started Read-only boolean field indicating if the timer has been
|
||||||
-- @class table
|
-- started.
|
||||||
-- @name timer
|
-- @table timer
|
||||||
|
|
||||||
local timer = { mt = {} }
|
local timer = { mt = {} }
|
||||||
|
|
||||||
|
@ -81,7 +82,11 @@ local timer_instance_mt = {
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
local function new(args)
|
--- Create a new timer object.
|
||||||
|
-- @tparam table args Arguments.
|
||||||
|
-- @tparam number args.timeout Timeout in seconds (e.g. 1.5).
|
||||||
|
-- @treturn timer
|
||||||
|
timer.new = function(args)
|
||||||
local ret = object()
|
local ret = object()
|
||||||
|
|
||||||
ret:add_signal("property::timeout")
|
ret:add_signal("property::timeout")
|
||||||
|
@ -109,7 +114,7 @@ capi.awesome.connect_signal("refresh", function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Call the given function at the end of the current main loop iteration
|
--- Call the given function at the end of the current main loop iteration
|
||||||
-- @param callback The function that should be called
|
-- @tparam function callback The function that should be called
|
||||||
-- @param ... Arguments to the callback function
|
-- @param ... Arguments to the callback function
|
||||||
function timer.delayed_call(callback, ...)
|
function timer.delayed_call(callback, ...)
|
||||||
assert(type(callback) == "function", "callback must be a function, got: " .. type(callback))
|
assert(type(callback) == "function", "callback must be a function, got: " .. type(callback))
|
||||||
|
@ -117,7 +122,7 @@ function timer.delayed_call(callback, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function timer.mt:__call(...)
|
function timer.mt:__call(...)
|
||||||
return new(...)
|
return timer.new(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(timer, timer.mt)
|
return setmetatable(timer, timer.mt)
|
||||||
|
|
Loading…
Reference in New Issue