/**
 * Bus is used to dispatch high-level runtime events.
 *
 * @author Sergei Lissovski <sergei.lissovski@modera.org>
 */
Ext.define('MF.runtime.EventBus', {
    mixins: {
        observable: 'Ext.util.Observable'
    },

    constructor: function (config) {
        this.mixins.observable.constructor.call(this, config || {});

        // ext6compatibility
        if (Ext.getVersion().major <= 4) {
            // TODO: consider getting rid of xxx.event_name syntax, it looks kind of ugly when docs are generated using
            // JSDuck

            this.addEvents(
                /**
                 * @event security.auth_success
                 * @param {Object}  data  The object would normally contain user-related information, preferences
                 *                        and important configuration required for runtime to work properly
                 */
                'security.auth_success',
                /**
                 * @event runtime.before_section_loaded
                 * @param {Ext.app.Controller} workbenchController
                 * @param {MF.runtime.Section} previouslyLoadedSectionController
                 * @param {MF.runtime.Section} currentlyLoadedSectionController
                 */
                'runtime.before_section_loaded',
                /**
                 * Fired only only once, when MJR has been initialized and first section has been loaded.
                 *
                 * @event runtime.section_loaded
                 * @param {Ext.app.Controller} viewportController
                 * @param {MF.runtime.Section} currentlyLoadedSectionController
                 */
                'runtime.section_loaded',
                /**
                 * Fired every time when section is changed, this event is not going to be fired when runtime is
                 * initialized for the first time.
                 *
                 * @event runtime.section_loaded
                 * @param {Ext.app.Controller} workbenchController
                 * @param {MF.runtime.Section} previouslyLoadedSectionController
                 * @param {MF.runtime.Section} currentlyLoadedSectionController
                 */
                'runtime.section_changed',
                /**
                 * @event runtime.workbench_loaded
                 * @param {Ext.Component} workbenchUi
                 * @param {MF.runtime.applications.authenticationaware.controller.Workbench} workbenchController
                 */
                'runtime.workbench_loaded'
            );
        }
    }
});