Changeset

1181:dffbb7d1da4b

util.events: Dispatch code now accepts a variable number of arguments
author Waqas Hussain <waqas20@gmail.com>
date Sun, 17 May 2009 04:50:32 +0500
parents 1180:8c5d945c1f35
children 1182:89e9f0d555a2
files util/events.lua
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/util/events.lua	Sun May 17 02:06:35 2009 +0500
+++ b/util/events.lua	Sun May 17 04:50:32 2009 +0500
@@ -52,9 +52,9 @@
 	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 @@
 	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