Files
lua-matrix/matrix/eventable.lua
Adrian Perez de Castro 99fbf8eb28 First pass at an event-based notification facilty
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).
2016-06-30 00:24:24 +03:00

2.3 KiB