Software /
code /
prosody
Changeset
7039:138241cc1b3a
util.events: Document data structures
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 23 Dec 2015 11:17:26 +0000 |
parents | 7037:5d52e4ee2ae1 |
children | 7040:bdcea2dd33b8 |
files | util/events.lua |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/events.lua Fri Jan 01 19:53:45 2016 +0100 +++ b/util/events.lua Wed Dec 23 11:17:26 2015 +0000 @@ -17,10 +17,15 @@ local _ENV = nil; local function new() + -- Map event name to ordered list of handlers (lazily built): handlers[event_name] = array_of_handler_functions local handlers = {}; + -- Array of wrapper functions that wrap all events (nil if empty) local global_wrappers; + -- Per-event wrappers: wrappers[event_name] = wrapper_function local wrappers = {}; + -- Event map: event_map[handler_function] = priority_number local event_map = {}; + -- Called on-demand to build handlers entries local function _rebuild_index(handlers, event) local _handlers = event_map[event]; if not _handlers or next(_handlers) == nil then return; end