Custom Events Model without using DOM events in JavaScript
If you want to make a completely stand alone event system without relying on DOM events you can have something like this using reactor pattern function Event(name){ this.name = name; this.callbacks = []; } Event.prototype.registerCallback = function(callback){ this.callbacks.push(callback); } function Reactor(){ this.events = {}; } Reactor.prototype.registerEvent = function(eventName){ var event = new Event(eventName); this.events[eventName] = … Read more