blob: b7e9d6b42459d47dffdda4b6cdf054d683b961d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
local SignalManager = {}
SignalManager.signals = {}
function SignalManager.addCallback(self, signal, func)
if not self.signals[signal] then self.signals[signal] = {} end
self.signals[signal][func] = true
end
function SignalManager.removeCallback(self, signal, func)
if self.signals[signal] then
self.signals[signal][func] = nil
end
end
function SignalManager.emit(self, signal, argtable)
local sig = self.signals[signal]
if not sig then return end
for f, _ in pairs(sig) do
f(argtable)
end
end
return SignalManager
|