src/preferences/PreferencesBase.js
function () {
            if (this._saveInProgress) {
                if (!this._nextSaveDeferred) {
                    this._nextSaveDeferred = new $.Deferred();
                }
                return this._nextSaveDeferred.promise();
            }

            var deferred = this._nextSaveDeferred || (new $.Deferred());
            this._saveInProgress = true;
            this._nextSaveDeferred = null;

            Async.doInParallel(_.values(this._scopes), function (scope) {
                if (scope) {
                    return scope.save();
                } else {
                    return (new $.Deferred()).resolve().promise();
                }
            }.bind(this))
                .then(function () {
                    this._saveInProgress = false;
                    if (this._nextSaveDeferred) {
                        this.save();
                    }
                    deferred.resolve();
                }.bind(this))
                .fail(function (err) {
                    deferred.reject(err);
                });

            return deferred.promise();
        }
function () {
            if (this._saveInProgress) {
                if (!this._nextSaveDeferred) {
                    this._nextSaveDeferred = new $.Deferred();
                }
                return this._nextSaveDeferred.promise();
            }

            var deferred = this._nextSaveDeferred || (new $.Deferred());
            this._saveInProgress = true;
            this._nextSaveDeferred = null;

            Async.doInParallel(_.values(this._scopes), function (scope) {
                if (scope) {
                    return scope.save();
                } else {
                    return (new $.Deferred()).resolve().promise();
                }
            }.bind(this))
                .then(function () {
                    this._saveInProgress = false;
                    if (this._nextSaveDeferred) {
                        this.save();
                    }
                    deferred.resolve();
                }.bind(this))
                .fail(function (err) {
                    deferred.reject(err);
                });

            return deferred.promise();
        }
function ( ) { if ( this . _saveInProgress ) { if ( ! this . _nextSaveDeferred ) { this . _nextSaveDeferred = new $ . Deferred ( ) ; } return this . _nextSaveDeferred . promise ( ) ; } var deferred = this . _nextSaveDeferred || ( new $ . Deferred ( ) ) ; this . _saveInProgress = true ; this . _nextSaveDeferred = null ; Async . doInParallel ( _ . values ( this . _scopes ) , function ( scope ) { if ( scope ) { return scope . save ( ) ; } else { return ( new $ . Deferred ( ) ) . resolve ( ) . promise ( ) ; } } . bind ( this ) ) . then ( function ( ) { this . _saveInProgress = false ; if ( this . _nextSaveDeferred ) { this . save ( ) ; } deferred . resolve ( ) ; } . bind ( this ) ) . fail ( function ( err ) { deferred . reject ( err ) ; } ) ; return deferred . promise ( ) ; }
Saves the preferences. If a save is already in progress, a Promise is returned for
that save operation.

@return {Promise} Resolved when the preferences are done saving.
Saves the preferences . If a save is already in progress a Promise is returned for that save operation .