Comparison

util/events.lua @ 6641:b44ebfe81c73

util.events: Change from nil to false to indicate adding a global wrapper
author Matthew Wild <mwild1@gmail.com>
date Tue, 28 Apr 2015 14:19:28 +0100
parent 6638:9d2b56fd6b47
child 6648:999434eb1bbf
child 6664:5466f24e51c9
comparison
equal deleted inserted replaced
6640:859e9af53aa1 6641:b44ebfe81c73
91 end 91 end
92 return _fire_event(event_name, event_data); 92 return _fire_event(event_name, event_data);
93 end 93 end
94 local function add_wrapper(event_name, wrapper) 94 local function add_wrapper(event_name, wrapper)
95 local w; 95 local w;
96 if event_name == nil then 96 if event_name == false then
97 w = global_wrappers; 97 w = global_wrappers;
98 if not w then 98 if not w then
99 w = {}; 99 w = {};
100 global_wrappers = w; 100 global_wrappers = w;
101 end 101 end
108 end 108 end
109 w[#w+1] = wrapper; 109 w[#w+1] = wrapper;
110 end 110 end
111 local function remove_wrapper(event_name, wrapper) 111 local function remove_wrapper(event_name, wrapper)
112 local w; 112 local w;
113 if event_name == nil then 113 if event_name == false then
114 w = global_wrappers; 114 w = global_wrappers;
115 else 115 else
116 w = wrappers[event_name]; 116 w = wrappers[event_name];
117 end 117 end
118 if not w then return; end 118 if not w then return; end