Base class to add on()
and emit()
methods to a class for listening for events and emitting events.
- Source:
Example
var EventedSubClass = dcl(Evented, {...});
var instance = new EventedSubClass();
instance.on("open", function (event) {
... do something with event
});
instance.emit("open", {name: "some event", ...});
Methods
-
emit(type, var_args)
-
Emit specified event.
Parameters:
Name Type Argument Description type
string Name of event.
var_args
anything <repeatable>
Parameters to pass to the listeners for this event.
- Source:
-
on(type, listener) → {Object}
-
Setup listener to be called when specified event is fired.
Parameters:
Name Type Description type
string Name of event.
listener
function Callback for when event occurs.
- Source:
Returns:
Handle with
destroy()
method to stop listening to event.- Type
- Object