lib/Sync.js
function(changedModel, options) {

        // Don't update unless the model is different
        var newModel = model.syncMonitor.get('model');
        if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(newModel)))) {
          log.info('monitorListener.noChanges', t.className, newModel);
          return;
        }

        // Disconnect if the model was deleted or the ID isn't the same
        var isDeleted = (_.size(newModel) === 0);
        if (isDeleted || newModel.id !== modelId)  {
          log.info('modelListener.deleted', t.className, newModel);
          disconnectListeners();
        }

        // Forward changes to the model (including server-side delete)
        var newOpts = {isSyncChanging:true};
        if (isDeleted) {
          log.info('modelListener.deleting', t.className, newModel);
          model.clear(newOpts);
        } else {
          // Make sure the model is set to exactly the new contents (vs. override)
          log.info('modelListener.setting', t.className, newModel);
          model.clear({silent:true});
          model.set(newModel, newOpts);
        }
      }
function(changedModel, options) {

        // Don't update unless the model is different
        var newModel = model.syncMonitor.get('model');
        if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(newModel)))) {
          log.info('monitorListener.noChanges', t.className, newModel);
          return;
        }

        // Disconnect if the model was deleted or the ID isn't the same
        var isDeleted = (_.size(newModel) === 0);
        if (isDeleted || newModel.id !== modelId)  {
          log.info('modelListener.deleted', t.className, newModel);
          disconnectListeners();
        }

        // Forward changes to the model (including server-side delete)
        var newOpts = {isSyncChanging:true};
        if (isDeleted) {
          log.info('modelListener.deleting', t.className, newModel);
          model.clear(newOpts);
        } else {
          // Make sure the model is set to exactly the new contents (vs. override)
          log.info('modelListener.setting', t.className, newModel);
          model.clear({silent:true});
          model.set(newModel, newOpts);
        }
      }
function ( changedModel , options ) { // Don't update unless the model is different var newModel = model . syncMonitor . get ( 'model' ) ; if ( _ . isEqual ( JSON . parse ( JSON . stringify ( model ) ) , JSON . parse ( JSON . stringify ( newModel ) ) ) ) { log . info ( 'monitorListener.noChanges' , t . className , newModel ) ; return ; } // Disconnect if the model was deleted or the ID isn't the same var isDeleted = ( _ . size ( newModel ) === 0 ) ; if ( isDeleted || newModel . id !== modelId ) { log . info ( 'modelListener.deleted' , t . className , newModel ) ; disconnectListeners ( ) ; } // Forward changes to the model (including server-side delete) var newOpts = { isSyncChanging : true } ; if ( isDeleted ) { log . info ( 'modelListener.deleting' , t . className , newModel ) ; model . clear ( newOpts ) ; } else { // Make sure the model is set to exactly the new contents (vs. override) log . info ( 'modelListener.setting' , t . className , newModel ) ; model . clear ( { silent : true } ) ; model . set ( newModel , newOpts ) ; } }
Server-side listener - for updating server changes into the model
Server - side listener - for updating server changes into the model