aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-09-17 04:09:58 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-09-17 04:09:58 +0500
commitaf976e466d7c0a0ffadf51525a626d86f9414cd0 (patch)
tree54df65c263f7e45d912a6e7cfd1e6d0ad305531d
parent3da6413681341e250a56c0f7ed1946545718306e (diff)
downloadprosody-af976e466d7c0a0ffadf51525a626d86f9414cd0.tar.gz
prosody-af976e466d7c0a0ffadf51525a626d86f9414cd0.zip
util.events: Removed dispatcher creation functions (these weren't being used).
-rw-r--r--util/events.lua32
1 files changed, 1 insertions, 31 deletions
diff --git a/util/events.lua b/util/events.lua
index 363d2ac6..65b3b00b 100644
--- a/util/events.lua
+++ b/util/events.lua
@@ -7,16 +7,13 @@
--
-local ipairs = ipairs;
local pairs = pairs;
local t_insert = table.insert;
local t_sort = table.sort;
-local select = select;
module "events"
function new()
- local dispatchers = {};
local handlers = {};
local event_map = {};
local function _rebuild_index(event) -- TODO optimize index rebuilding
@@ -57,22 +54,7 @@ function new()
remove_handler(event, handler);
end
end;
- local function _create_dispatcher(event) -- FIXME duplicate code in fire_event
- local h = handlers[event];
- if not h then h = {}; handlers[event] = h; end
- local dispatcher = function(...)
- for i=1,#h do
- local ret = h[i](...);
- if ret ~= nil then return ret; end
- end
- end;
- dispatchers[event] = dispatcher;
- return dispatcher;
- end;
- local function get_dispatcher(event)
- return dispatchers[event] or _create_dispatcher(event);
- end;
- local function fire_event(event, ...) -- FIXME duplicates dispatcher code
+ local function fire_event(event, ...)
local h = handlers[event];
if h then
for i=1,#h do
@@ -81,24 +63,12 @@ function new()
end
end
end;
- local function get_named_arg_dispatcher(event, ...)
- local dispatcher = get_dispatcher(event);
- local keys = {...};
- local data = {};
- return function(...)
- for i, key in ipairs(keys) do data[key] = select(i, ...); end
- dispatcher(data);
- end;
- end;
return {
add_handler = add_handler;
remove_handler = remove_handler;
add_plugin = add_plugin;
remove_plugin = remove_plugin;
- get_dispatcher = get_dispatcher;
fire_event = fire_event;
- get_named_arg_dispatcher = get_named_arg_dispatcher;
- _dispatchers = dispatchers;
_handlers = handlers;
_event_map = event_map;
};