trigger (name, args) public
Triggers a named event for the object. Any additional arguments will be passed as parameters to the functions that are subscribed to the event.
person.on('didEat', function(food) {
console.log('person ate some ' + food);
});
person.trigger('didEat', 'broccoli');
// outputs: person ate some broccoli
Parameters:
-
name
String - The name of the event
-
args
Object... - Optional arguments to pass on
Please login to continue.