From b782b7ad9249b259bcdc646732129828d6101b62 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 17 May 2009 04:50:32 +0500 Subject: util.events: Dispatch code now accepts a variable number of arguments --- util/events.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'util') 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 -- cgit v1.2.3