Software /
code /
prosody
Changeset
1146:542d49518d3a
util.events: event handlers can now return a result, which also interrupts further handling of the event
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 15 May 2009 06:23:55 +0500 |
parents | 1145:06051191913d |
children | 1147:513c1d071045 |
files | util/events.lua |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/util/events.lua Wed May 13 23:24:49 2009 +0500 +++ b/util/events.lua Fri May 15 06:23:55 2009 +0500 @@ -53,7 +53,8 @@ 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 @@ 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;