src/LiveDevelopment/LiveDevelopment.js
function loadAgents() {
        // If we're already loading agents return same promise
        if (_loadAgentsPromise) {
            return _loadAgentsPromise;
        }

        var result = new $.Deferred(),
            allAgentsPromise;

        _loadAgentsPromise = result.promise();

        _setStatus(STATUS_LOADING_AGENTS);

        // load agents in parallel
        allAgentsPromise = Async.doInParallel(
            getEnabledAgents(),
            function (name) {
                return _invokeAgentMethod(name, "load").done(function () {
                    _loadedAgentNames.push(name);
                });
            },
            true
        );

        // wrap agent loading with a timeout
        allAgentsPromise = Async.withTimeout(allAgentsPromise, 10000);

        allAgentsPromise.done(function () {
            var doc = (_liveDocument) ? _liveDocument.doc : null;

            if (doc) {
                var status = STATUS_ACTIVE;

                if (_docIsOutOfSync(doc)) {
                    status = STATUS_OUT_OF_SYNC;
                }

                _setStatus(status);
                result.resolve();
            } else {
                result.reject();
            }
        });

        allAgentsPromise.fail(result.reject);

        _loadAgentsPromise
            .fail(function () {
                // show error loading live dev dialog
                _setStatus(STATUS_ERROR);

                Dialogs.showModalDialog(
                    Dialogs.DIALOG_ID_ERROR,
                    Strings.LIVE_DEVELOPMENT_ERROR_TITLE,
                    _makeTroubleshootingMessage(Strings.LIVE_DEV_LOADING_ERROR_MESSAGE)
                );
            })
            .always(function () {
                _loadAgentsPromise = null;
            });

        return _loadAgentsPromise;
    }
function loadAgents() {
        // If we're already loading agents return same promise
        if (_loadAgentsPromise) {
            return _loadAgentsPromise;
        }

        var result = new $.Deferred(),
            allAgentsPromise;

        _loadAgentsPromise = result.promise();

        _setStatus(STATUS_LOADING_AGENTS);

        // load agents in parallel
        allAgentsPromise = Async.doInParallel(
            getEnabledAgents(),
            function (name) {
                return _invokeAgentMethod(name, "load").done(function () {
                    _loadedAgentNames.push(name);
                });
            },
            true
        );

        // wrap agent loading with a timeout
        allAgentsPromise = Async.withTimeout(allAgentsPromise, 10000);

        allAgentsPromise.done(function () {
            var doc = (_liveDocument) ? _liveDocument.doc : null;

            if (doc) {
                var status = STATUS_ACTIVE;

                if (_docIsOutOfSync(doc)) {
                    status = STATUS_OUT_OF_SYNC;
                }

                _setStatus(status);
                result.resolve();
            } else {
                result.reject();
            }
        });

        allAgentsPromise.fail(result.reject);

        _loadAgentsPromise
            .fail(function () {
                // show error loading live dev dialog
                _setStatus(STATUS_ERROR);

                Dialogs.showModalDialog(
                    Dialogs.DIALOG_ID_ERROR,
                    Strings.LIVE_DEVELOPMENT_ERROR_TITLE,
                    _makeTroubleshootingMessage(Strings.LIVE_DEV_LOADING_ERROR_MESSAGE)
                );
            })
            .always(function () {
                _loadAgentsPromise = null;
            });

        return _loadAgentsPromise;
    }
function loadAgents ( ) { // If we're already loading agents return same promise if ( _loadAgentsPromise ) { return _loadAgentsPromise ; } var result = new $ . Deferred ( ) , allAgentsPromise ; _loadAgentsPromise = result . promise ( ) ; _setStatus ( STATUS_LOADING_AGENTS ) ; // load agents in parallel allAgentsPromise = Async . doInParallel ( getEnabledAgents ( ) , function ( name ) { return _invokeAgentMethod ( name , "load" ) . done ( function ( ) { _loadedAgentNames . push ( name ) ; } ) ; } , true ) ; // wrap agent loading with a timeout allAgentsPromise = Async . withTimeout ( allAgentsPromise , 10000 ) ; allAgentsPromise . done ( function ( ) { var doc = ( _liveDocument ) ? _liveDocument . doc : null ; if ( doc ) { var status = STATUS_ACTIVE ; if ( _docIsOutOfSync ( doc ) ) { status = STATUS_OUT_OF_SYNC ; } _setStatus ( status ) ; result . resolve ( ) ; } else { result . reject ( ) ; } } ) ; allAgentsPromise . fail ( result . reject ) ; _loadAgentsPromise . fail ( function ( ) { // show error loading live dev dialog _setStatus ( STATUS_ERROR ) ; Dialogs . showModalDialog ( Dialogs . DIALOG_ID_ERROR , Strings . LIVE_DEVELOPMENT_ERROR_TITLE , _makeTroubleshootingMessage ( Strings . LIVE_DEV_LOADING_ERROR_MESSAGE ) ) ; } ) . always ( function ( ) { _loadAgentsPromise = null ; } ) ; return _loadAgentsPromise ; }
Load the agents
Load the agents