diff options
author | sanine-a <sanine.not@pm.me> | 2020-12-04 22:23:02 -0600 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2020-12-04 22:23:02 -0600 |
commit | c5fd6a98d29c8790c266da2c6b6db2ab173c3064 (patch) | |
tree | d1a6898ced92084420fbfb012873b4ead14be08e /demo/SignalManager.lua | |
parent | e767e1ff9d81f8a76196caab91d9b6b4bbe0b30e (diff) |
add SignalManager.lua and revert to old Node.lua
Diffstat (limited to 'demo/SignalManager.lua')
-rw-r--r-- | demo/SignalManager.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/demo/SignalManager.lua b/demo/SignalManager.lua new file mode 100644 index 0000000..b7e9d6b --- /dev/null +++ b/demo/SignalManager.lua @@ -0,0 +1,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 |