src/object.js
function(serverData) {
        // Grab a copy of any object referenced by this object. These instances
        // may have already been fetched, and we don't want to lose their data.
        // Note that doing it like this means we will unify separate copies of the
        // same object, but that's a risk we have to take.
        var fetchedObjects = {};
        AV._traverse(this.attributes, function(object) {
          if (object instanceof AV.Object && object.id && object._hasData) {
            fetchedObjects[object.id] = object;
          }
        });

        var savedChanges = _.first(this._opSetQueue);
        this._opSetQueue = _.rest(this._opSetQueue);
        this._applyOpSet(savedChanges, this._serverData);
        this._mergeMagicFields(serverData);
        var self = this;
        AV._objectEach(serverData, function(value, key) {
          self._serverData[key] = AV._decode(value, key);

          // Look for any objects that might have become unfetched and fix them
          // by replacing their values with the previously observed values.
          var fetched = AV._traverse(self._serverData[key], function(object) {
            if (object instanceof AV.Object && fetchedObjects[object.id]) {
              return fetchedObjects[object.id];
            }
          });
          if (fetched) {
            self._serverData[key] = fetched;
          }
        });
        this._rebuildAllEstimatedData();
        const opSetQueue = this._opSetQueue.map(_.clone);
        this._refreshCache();
        this._opSetQueue = opSetQueue;
        this._saving = this._saving - 1;
      }
function(serverData) {
        // Grab a copy of any object referenced by this object. These instances
        // may have already been fetched, and we don't want to lose their data.
        // Note that doing it like this means we will unify separate copies of the
        // same object, but that's a risk we have to take.
        var fetchedObjects = {};
        AV._traverse(this.attributes, function(object) {
          if (object instanceof AV.Object && object.id && object._hasData) {
            fetchedObjects[object.id] = object;
          }
        });

        var savedChanges = _.first(this._opSetQueue);
        this._opSetQueue = _.rest(this._opSetQueue);
        this._applyOpSet(savedChanges, this._serverData);
        this._mergeMagicFields(serverData);
        var self = this;
        AV._objectEach(serverData, function(value, key) {
          self._serverData[key] = AV._decode(value, key);

          // Look for any objects that might have become unfetched and fix them
          // by replacing their values with the previously observed values.
          var fetched = AV._traverse(self._serverData[key], function(object) {
            if (object instanceof AV.Object && fetchedObjects[object.id]) {
              return fetchedObjects[object.id];
            }
          });
          if (fetched) {
            self._serverData[key] = fetched;
          }
        });
        this._rebuildAllEstimatedData();
        const opSetQueue = this._opSetQueue.map(_.clone);
        this._refreshCache();
        this._opSetQueue = opSetQueue;
        this._saving = this._saving - 1;
      }
function ( serverData ) { // Grab a copy of any object referenced by this object. These instances // may have already been fetched, and we don't want to lose their data. // Note that doing it like this means we will unify separate copies of the // same object, but that's a risk we have to take. var fetchedObjects = { } ; AV . _traverse ( this . attributes , function ( object ) { if ( object instanceof AV . Object && object . id && object . _hasData ) { fetchedObjects [ object . id ] = object ; } } ) ; var savedChanges = _ . first ( this . _opSetQueue ) ; this . _opSetQueue = _ . rest ( this . _opSetQueue ) ; this . _applyOpSet ( savedChanges , this . _serverData ) ; this . _mergeMagicFields ( serverData ) ; var self = this ; AV . _objectEach ( serverData , function ( value , key ) { self . _serverData [ key ] = AV . _decode ( value , key ) ; // Look for any objects that might have become unfetched and fix them // by replacing their values with the previously observed values. var fetched = AV . _traverse ( self . _serverData [ key ] , function ( object ) { if ( object instanceof AV . Object && fetchedObjects [ object . id ] ) { return fetchedObjects [ object . id ] ; } } ) ; if ( fetched ) { self . _serverData [ key ] = fetched ; } } ) ; this . _rebuildAllEstimatedData ( ) ; const opSetQueue = this . _opSetQueue . map ( _ . clone ) ; this . _refreshCache ( ) ; this . _opSetQueue = opSetQueue ; this . _saving = this . _saving - 1 ; }
Called when a save completes successfully. This merges the changes that
were saved into the known server data, and overrides it with any data
sent directly from the server.
@private
Called when a save completes successfully . This merges the changes that were saved into the known server data and overrides it with any data sent directly from the server .