Event
Summary
The Event class defines and manage events
Methods
dispatch
Syntax
dispatch
(
-
event
-
instance
Summary
Dispatch event
Parameters:
-
event
StringName of the event
-
instance
ObjectInstance for scope
Example:
Mootor.dispatch("myCustomEvent", myInstance);
extend
Syntax
extend
(
-
object
-
objectName
Summary
Extend objects with Event methods
Parameters:
-
object
ObjectObject to extend
-
objectName
StringString 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:
-
event
StringName of the event
-
callback
FunctionCallback function\
Example:
Mootor.on("myCustomEvent", function(self) {
console.log("Event fired!");
});