Event
Summary
The Event class defines and manage events
Methods
dispatch
Syntax
dispatch
(
-
event -
instance
Summary
Dispatch event
Parameters:
-
eventStringName of the event
-
instanceObjectInstance for scope
Example:
Mootor.dispatch("myCustomEvent", myInstance);
extend
Syntax
extend
(
-
object -
objectName
Summary
Extend objects with Event methods
Parameters:
-
objectObjectObject to extend
-
objectNameStringString name of the object
Example:
Person = function(name) {
this.name = name;
}
Mootor.Event.extend(Person.prototype);
person = new Person("Anon");
person.on("fire", function(self) {
console.log(self.name + " is on fire!");
}
person.dispatch("fire", person);
on
Syntax
on
(
-
event -
callback
Summary
Add event to collection
Parameters:
-
eventStringName of the event
-
callbackFunctionCallback function\
Example:
Mootor.on("myCustomEvent", function(self) {
console.log("Event fired!");
});