aboutsummaryrefslogtreecommitdiffstats
path: root/util/events.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-05-15 06:23:55 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-05-15 06:23:55 +0500
commitcfc9bf6a35007ef2a62e2a668b8c659fd2b24992 (patch)
tree4874238b351bb756339827c44886ae307526fe59 /util/events.lua
parentd5869e099aa7a994ff378934264e1110e9204c89 (diff)
downloadprosody-cfc9bf6a35007ef2a62e2a668b8c659fd2b24992.tar.gz
prosody-cfc9bf6a35007ef2a62e2a668b8c659fd2b24992.zip
util.events: event handlers can now return a result, which also interrupts further handling of the event
Diffstat (limited to 'util/events.lua')
-rw-r--r--util/events.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/events.lua b/util/events.lua
index b1f3811c..704d31a4 100644
--- a/util/events.lua
+++ b/util/events.lua
@@ -53,7 +53,8 @@ function new()
if not h then h = {}; handlers[event] = h; end
local dispatcher = function(data)
for _, handler in ipairs(h) do
- handler(data);
+ local ret = handler(data);
+ if ret ~= nil then return ret; end
end
end;
dispatchers[event] = dispatcher;
@@ -66,7 +67,8 @@ function new()
local h = handlers[event];
if h then
for _, handler in ipairs(h) do
- handler(data);
+ local ret = handler(data);
+ if ret ~= nil then return ret; end
end
end
end;