let's say I have javascript class.
function myClass(){
function someProcess(){
listeners.init();
}
var listeners = {
init: function(){},
message: function(){}
}
return {
on: function( prop ) {
if ( listeners.hasOwnProperty( prop ) ) {
return listeners[ prop ];
}
}
}
}
and then someone creates object like so and uses my custom event
var c = new myClass();
c.on('init', function(){
console.log('init executed');
});
now i want to execute init from my someProcess() method(which is in myClass). So idea is that register custom events and then trigger them from inside my class.