/**
 * Created by aheadware
 */

"use strict";

var app = app || {};
app.core = app.core || {};

/**
 *
 * Dependencies:
 * SHOTGUN
 * https://github.com/jgnewman/shotgun
 */
app.core.EventManager = (function(){

    return {
        /**
         * Init
         */
        init : function()
        {
            // Nothing to initialize
        }
        ,
        /**
         *
         * @param eventName
         * @param callbackId
         */
        off : function( eventName, callbackId )
        {
            // Additional checking is required since SHOTGUN library throws an error otherwise
            let es = SHOTGUN.getEvents();
            if ( ( "object" === typeof es ) && es.hasOwnProperty( eventName ) )
            {
                SHOTGUN.remove( eventName, callbackId );
            }
        }
        ,
        /**
         *
         * @param eventName
         * @param callback
         * @returns {*}
         */
        on : function( eventName, callback )
        {
            return SHOTGUN.listen( eventName, callback );
        }
        ,
        /**
         *
         * @param eventName
         * @param data
         */
        trigger : function( eventName, data )
        {
            SHOTGUN.fire( eventName, data );
        }
    };

})();