diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-05-15 06:23:55 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-05-15 06:23:55 +0500 |
commit | cfc9bf6a35007ef2a62e2a668b8c659fd2b24992 (patch) | |
tree | 4874238b351bb756339827c44886ae307526fe59 | |
parent | d5869e099aa7a994ff378934264e1110e9204c89 (diff) | |
download | prosody-cfc9bf6a35007ef2a62e2a668b8c659fd2b24992.tar.gz prosody-cfc9bf6a35007ef2a62e2a668b8c659fd2b24992.zip |
util.events: event handlers can now return a result, which also interrupts further handling of the event
-rw-r--r-- | util/events.lua | 6 |
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;
|