mirror of
https://github.com/kikito/beholder.lua.git
synced 2024-12-16 00:34:21 +00:00
refactor
This commit is contained in:
parent
5f0009605c
commit
3131f2d158
@ -19,7 +19,7 @@ local function findNodeById(self, id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function createNode(self, event)
|
local function createNode(self, event)
|
||||||
self._nodes[event] = {}
|
self._nodes[event] = {actions = {}}
|
||||||
return self._nodes[event]
|
return self._nodes[event]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,13 +29,13 @@ end
|
|||||||
|
|
||||||
local function registerActionInNode(self, node, action)
|
local function registerActionInNode(self, node, action)
|
||||||
local id = {}
|
local id = {}
|
||||||
node[id] = action
|
node.actions[id] = action
|
||||||
self._ids[id] = node
|
self._ids[id] = node
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
local function unregisterActionFromNode(self, node, id)
|
local function unregisterActionFromNode(self, node, id)
|
||||||
node[id] = nil
|
node.actions[id] = nil
|
||||||
self._ids[id] = nil
|
self._ids[id] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ end
|
|||||||
|
|
||||||
function beholder:trigger(event,...)
|
function beholder:trigger(event,...)
|
||||||
local node = findNode(self, event) or {}
|
local node = findNode(self, event) or {}
|
||||||
for _,action in pairs(node) do
|
for _,action in pairs(node.actions) do
|
||||||
action(...)
|
action(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user