[signal] Fix module name and summary.
This commit is contained in:
parent
9928899df1
commit
dba877a190
26
signal.lua
26
signal.lua
|
@ -1,4 +1,4 @@
|
|||
--- Timer utilities.
|
||||
--- Signal utilities.
|
||||
--
|
||||
-- This is a reworked implementation of the original signal module
|
||||
-- from the hump library (https://github.com/vrld/hump).
|
||||
|
@ -7,7 +7,7 @@
|
|||
-- It offers functionality to register for and publish signals.
|
||||
-- Implements the Observer pattern.
|
||||
--
|
||||
-- @module gear.timer
|
||||
-- @module gear.signal
|
||||
-- @copyright 2010-2013 Matthias Richter
|
||||
-- @copyright 2022 The DoubleFourteen Code Forge
|
||||
-- @author Matthias Richter, Lorenzo Cogotti
|
||||
|
@ -21,6 +21,11 @@ Signal.__index = function(self, key)
|
|||
end)()
|
||||
end
|
||||
|
||||
|
||||
function Signal:new()
|
||||
return setmetatable({}, self)
|
||||
end
|
||||
|
||||
function Signal:register(s, f)
|
||||
self[s][f] = f
|
||||
return f
|
||||
|
@ -46,38 +51,39 @@ function Signal:clear(...)
|
|||
end
|
||||
end
|
||||
|
||||
function Signal:emitPattern(p, ...)
|
||||
function Signal:emitpattern(p, ...)
|
||||
for s in pairs(self) do
|
||||
if s:match(p) then self:emit(s, ...) end
|
||||
end
|
||||
end
|
||||
|
||||
function Signal:registerPattern(p, f)
|
||||
function Signal:registerpattern(p, f)
|
||||
for s in pairs(self) do
|
||||
if s:match(p) then self:register(s, f) end
|
||||
end
|
||||
return f
|
||||
end
|
||||
|
||||
function Signal:removePattern(p, ...)
|
||||
function Signal:removepattern(p, ...)
|
||||
for s in pairs(self) do
|
||||
if s:match(p) then self:remove(s, ...) end
|
||||
end
|
||||
end
|
||||
|
||||
function Signal:clearPattern(p)
|
||||
function Signal:clearpattern(p)
|
||||
for s in pairs(self) do
|
||||
if s:match(p) then self[s] = {} end
|
||||
end
|
||||
end
|
||||
|
||||
-- instancing
|
||||
function Signal.new()
|
||||
return setmetatable({}, Signal)
|
||||
function Signal:clearall()
|
||||
for s in pairs(self) do
|
||||
self[s] = {}
|
||||
end
|
||||
end
|
||||
|
||||
-- default instance
|
||||
local default = Signal.new()
|
||||
local default = Signal:new()
|
||||
|
||||
-- module forwards calls to default instance
|
||||
local module = {}
|
||||
|
|
Loading…
Reference in New Issue