Module core.EventSource
Holds a set of callbacks, that are associated with events, and provides a way to calling then. The order that the callbacks are called is undefined.
Functions
EventSource.new () | Constructor. |
EventSource:add (event, callback, arg) | Adds a callback to the set. |
EventSource:remove (event, callback) | Removes a callback from the set. |
EventSource:send (event, ...) | Sends an event to all registered callbacks. |
Functions
- EventSource.new ()
-
Constructor.
Return value:
New EventSource instance - EventSource:add (event, callback, arg)
-
Adds a callback to the set.
Parameters
- event: Event to listen
- callback: Callback to be called when the event occurs
- arg: Value to be passed as first argument of the callback (if nil, it isn't passed)
- EventSource:remove (event, callback)
-
Removes a callback from the set.
Parameters
- event: Event associated with the callback
- callback: Registered callback to be removed
- EventSource:send (event, ...)
-
Sends an event to all registered callbacks.
Parameters
- event: Event to send
- ...: Extra arguments to be passed (after the :add argument).