JSFiddle - React, Tailwind, and code Playground
JavaScript
function App(){
// event element
var evtElement = this; // can be any other
this.start = function(){
// do some code
$(evtElement).trigger('app.start');
}
this.finish = function(){
// do some code
$(evtElement).trigger('app.finish');
}
}
var myApp1 = new App();
var myApp2 = new App();
$(myApp1).bind('app.start', function(){
alert(1);
})
$(myApp2).bind('app.start', function(){
alert(2);
})
myApp1.start();
myApp2.start();