diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-05-17 04:50:32 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-05-17 04:50:32 +0500 |
commit | b782b7ad9249b259bcdc646732129828d6101b62 (patch) | |
tree | a090bf3c7780a2422579ef782ff5a3e85de2e99d | |
parent | ec51346b511ba986e6904603406e68e8f5b635f3 (diff) | |
download | prosody-b782b7ad9249b259bcdc646732129828d6101b62.tar.gz prosody-b782b7ad9249b259bcdc646732129828d6101b62.zip |
util.events: Dispatch code now accepts a variable number of arguments
-rw-r--r-- | util/events.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/util/events.lua b/util/events.lua index dc294a55..3816f30b 100644 --- a/util/events.lua +++ b/util/events.lua @@ -52,9 +52,9 @@ function new() 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(data)
+ local dispatcher = function(...)
for _, handler in ipairs(h) do
- local ret = handler(data);
+ local ret = handler(...);
if ret ~= nil then return ret; end
end
end;
@@ -64,11 +64,11 @@ function new() local function get_dispatcher(event)
return dispatchers[event] or _create_dispatcher(event);
end;
- local function fire_event(event, data) -- FIXME duplicates dispatcher code
+ local function fire_event(event, ...) -- FIXME duplicates dispatcher code
local h = handlers[event];
if h then
for _, handler in ipairs(h) do
- local ret = handler(data);
+ local ret = handler(...);
if ret ~= nil then return ret; end
end
end
|