forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppInit.js
More file actions
1 lines (1 loc) · 1.3 KB
/
AppInit.js
File metadata and controls
1 lines (1 loc) · 1.3 KB
1
define(function(require,exports,module){const Metrics=require("utils/Metrics");var HTML_READY="htmlReady",APP_READY="appReady",EXTENSIONS_LOADED="extensionsLoaded",_status={HTML_READY:!1,APP_READY:!1,EXTENSIONS_LOADED:!1},_callbacks={};function _callHandler(handler){try{handler()}catch(e){console.error("Exception when calling a 'brackets done loading' handler: "+e),console.log(e.stack);let supportStatus="Y";window.Phoenix.isSupportedBrowser||(supportStatus="N"),Metrics.countEvent(Metrics.EVENT_TYPE.ERROR,"appInit",`${supportStatus}-handlerFail`)}}function _dispatchReady(type){var i,myHandlers=_callbacks[type];for(_status[type]=!0,i=0;i<myHandlers.length;i++)_callHandler(myHandlers[i]);_callbacks[type]=[]}function _addListener(type,handler){_status[type]?_callHandler(handler):_callbacks[type].push(handler)}function appReady(handler){_addListener(APP_READY,handler)}function htmlReady(handler){_addListener(HTML_READY,handler)}function extensionsLoaded(handler){_addListener(EXTENSIONS_LOADED,handler)}_callbacks[HTML_READY]=[],_callbacks[APP_READY]=[],_callbacks[EXTENSIONS_LOADED]=[],exports.appReady=appReady,exports.htmlReady=htmlReady,exports.extensionsLoaded=extensionsLoaded,exports.HTML_READY=HTML_READY,exports.APP_READY=APP_READY,exports.EXTENSIONS_LOADED=EXTENSIONS_LOADED,exports._dispatchReady=_dispatchReady});