A javascript function to dispatch custom events through the method .on.
This is useful when you want to raise custom events from your class/function
var x = events();
var y = events();
x.on("move",function(e){
console.log("x ->" + e);
});
y.on("move",function(e){
console.log("y ->" + e);
});
x.dispatch("move","this is x calling");
y.dispatch("move","this is y calling");
See the live example.