summaryrefslogtreecommitdiff
path: root/demo/SignalManager.lua
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-12-04 22:23:02 -0600
committersanine-a <sanine.not@pm.me>2020-12-04 22:23:02 -0600
commitc5fd6a98d29c8790c266da2c6b6db2ab173c3064 (patch)
treed1a6898ced92084420fbfb012873b4ead14be08e /demo/SignalManager.lua
parente767e1ff9d81f8a76196caab91d9b6b4bbe0b30e (diff)
add SignalManager.lua and revert to old Node.lua
Diffstat (limited to 'demo/SignalManager.lua')
-rw-r--r--demo/SignalManager.lua24
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