src/observer.js
function() {
    var value = this.get();

    // Don't call the callback if `skipNextSync` was called on the observer
    if (this.skip || !this.callback) {
      this.skip = false;

      if (this.getChangeRecords) {
        // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and
        // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters
        // in bind-each)
        this.oldValue = diff.clone(value);
      } else {
        this.oldValue = value;
      }
    } else {
      var change;
      var useCompareBy = this.getChangeRecords &&
                         this.compareBy &&
                         Array.isArray(value) &&
                         Array.isArray(this.oldValue);

      if (useCompareBy) {
        var compareExpression = this.compareBy;
        var name = this.compareByName;
        var index = this.compareByIndex || '__index__';
        var ctx = this.context;
        var globals = this.observations.globals;
        var formatters = this.observations.formatters;
        var oldValue = this.oldValue;
        if (!name) {
          name = '__item__';
          // Turn "id" into "__item__.id"
          compareExpression = name + '.' + compareExpression;
        }

        var getCompareValue = expressions.parse(compareExpression, globals, formatters, name, index);
        changed = diff.values(value.map(getCompareValue, ctx), oldValue.map(getCompareValue, ctx));
      } else if (this.getChangeRecords) {
        changed = diff.values(value, this.oldValue);
      } else {
        changed = diff.basic(value, this.oldValue);
      }

      var oldValue = this.oldValue;

      if (this.getChangeRecords) {
        // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and
        // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters
        // in bind-each)
        this.oldValue = diff.clone(value);
      } else {
        this.oldValue = value;
      }

      // If an array has changed calculate the splices and call the callback.
      if (!changed && !this.forceUpdateNextSync) return;
      this.forceUpdateNextSync = false;
      if (Array.isArray(changed)) {
        this.callback.call(this.callbackContext, value, oldValue, changed);
      } else {
        this.callback.call(this.callbackContext, value, oldValue);
      }
    }
  }
function() {
    var value = this.get();

    // Don't call the callback if `skipNextSync` was called on the observer
    if (this.skip || !this.callback) {
      this.skip = false;

      if (this.getChangeRecords) {
        // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and
        // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters
        // in bind-each)
        this.oldValue = diff.clone(value);
      } else {
        this.oldValue = value;
      }
    } else {
      var change;
      var useCompareBy = this.getChangeRecords &&
                         this.compareBy &&
                         Array.isArray(value) &&
                         Array.isArray(this.oldValue);

      if (useCompareBy) {
        var compareExpression = this.compareBy;
        var name = this.compareByName;
        var index = this.compareByIndex || '__index__';
        var ctx = this.context;
        var globals = this.observations.globals;
        var formatters = this.observations.formatters;
        var oldValue = this.oldValue;
        if (!name) {
          name = '__item__';
          // Turn "id" into "__item__.id"
          compareExpression = name + '.' + compareExpression;
        }

        var getCompareValue = expressions.parse(compareExpression, globals, formatters, name, index);
        changed = diff.values(value.map(getCompareValue, ctx), oldValue.map(getCompareValue, ctx));
      } else if (this.getChangeRecords) {
        changed = diff.values(value, this.oldValue);
      } else {
        changed = diff.basic(value, this.oldValue);
      }

      var oldValue = this.oldValue;

      if (this.getChangeRecords) {
        // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and
        // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters
        // in bind-each)
        this.oldValue = diff.clone(value);
      } else {
        this.oldValue = value;
      }

      // If an array has changed calculate the splices and call the callback.
      if (!changed && !this.forceUpdateNextSync) return;
      this.forceUpdateNextSync = false;
      if (Array.isArray(changed)) {
        this.callback.call(this.callbackContext, value, oldValue, changed);
      } else {
        this.callback.call(this.callbackContext, value, oldValue);
      }
    }
  }
function ( ) { var value = this . get ( ) ; // Don't call the callback if `skipNextSync` was called on the observer if ( this . skip || ! this . callback ) { this . skip = false ; if ( this . getChangeRecords ) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this . oldValue = diff . clone ( value ) ; } else { this . oldValue = value ; } } else { var change ; var useCompareBy = this . getChangeRecords && this . compareBy && Array . isArray ( value ) && Array . isArray ( this . oldValue ) ; if ( useCompareBy ) { var compareExpression = this . compareBy ; var name = this . compareByName ; var index = this . compareByIndex || '__index__' ; var ctx = this . context ; var globals = this . observations . globals ; var formatters = this . observations . formatters ; var oldValue = this . oldValue ; if ( ! name ) { name = '__item__' ; // Turn "id" into "__item__.id" compareExpression = name + '.' + compareExpression ; } var getCompareValue = expressions . parse ( compareExpression , globals , formatters , name , index ) ; changed = diff . values ( value . map ( getCompareValue , ctx ) , oldValue . map ( getCompareValue , ctx ) ) ; } else if ( this . getChangeRecords ) { changed = diff . values ( value , this . oldValue ) ; } else { changed = diff . basic ( value , this . oldValue ) ; } var oldValue = this . oldValue ; if ( this . getChangeRecords ) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this . oldValue = diff . clone ( value ) ; } else { this . oldValue = value ; } // If an array has changed calculate the splices and call the callback. if ( ! changed && ! this . forceUpdateNextSync ) return ; this . forceUpdateNextSync = false ; if ( Array . isArray ( changed ) ) { this . callback . call ( this . callbackContext , value , oldValue , changed ) ; } else { this . callback . call ( this . callbackContext , value , oldValue ) ; } } }
Syncs this observer now, calling the callback immediately if there have been changes
Syncs this observer now calling the callback immediately if there have been changes