* Support debug-logging to stderr by defining the MATRIX_EVENTABLE_DEBUG_LOG
environment variable.
* Support for unhooking handlers from events.
* Simplify the low-level interface: eventable.functions() now returns the
created functions directly, cutting down on an intermediate table.
* A new eventable.object() allows adding :hook(), :unhook() and :fire()
methods to any table. Firing events always sends the table itself as first
event parameter when firing any event.
The matrix.eventable module/function returns a table with a pair of functions
which can be used to connect event handlers to events, and to generate them.
Basic usage is as follows:
obj = eventable()
obj.hook("event-name", print) -- Handle the event with "print"
obj.fire("event-name", "Hello, world") -- Prints "Hello, world"
This initial implementation has the following limitations:
* Event handlers are always invoked in the same order in which they have been
connected using the .hook() function.
* Individual event handlers cannot be disconnected. Only disconnecting all
handlers for en event at once is possible via .hook("event", nil).