Core/Events

Events proxy object. For inter-component communications, please register your events and please subscribe to your events from the events hub. This reduces coupling between components.

Usage example:

const Events = require('./Events');
var foo = {
    initialize: function() {
        // Register the event with the events hub.
        Events.register('mynamespaced:event', this);
    },
    action: function() {
        // Broadcast your event to the events hub.
        // The events hub will then broadcast this event to all its subscribers.
        this.trigger('mynamespaced:event');
    }
}

var bar = {
    initialize: function() {
        // Call a callback when the event is received.
        Events.on('mynamespaced:event', function() {
            alert('Event!');
        });
    }
}