App.EventHandler

Manages subscribers for events and invokes their callbacks whenever that event is triggered.

Example

// Model class:
function Widget() {
    this.eventHandler = new App.EventHandler();
}
Widget.prototype = {
    on: function(event, handler) {
        this.eventHandler.add(event, handler);
    },
    off: function(event, handler) {
        this.eventHandler.add(event, handler);
    },
    onResize: function() {
        this.eventHandler.trigger('resize', {'optional' : 'data'});
    },
};
// Subscriber:
function Chart(input) {
   this.widget = input.widget;
}
Chart.prototype = {
    initialize : function() {
        this.widget.on('resize', function(data) {
            App.log.debug('The widget was resized');
        });
    }
};

Classes

EventHandler

Members

(static) window.App.EventHandler :EventHandler

Type:
  • EventHandler