packages/rebound-data/lib/computed-property.js
function(){
    var root = this.__root__;
    var context = this.__parent__;
    root.__computedDeps || (root.__computedDeps = {});

    _.each(this.deps, function(path){

      // For each dependancy, mark ourselves as dirty if they become dirty
      var dep = root.get(path, {raw: true, isPath: true});
      if(dep && dep.isComputedProperty){ dep.on('dirty', this.markDirty); }

      // Find actual context and path from relative paths
      var split = $.splitPath(path);
      while(split[0] === '@parent'){
        context = context.__parent__;
        split.shift();
      }
      path = context.__path().replace(/\.?\[.*\]/ig, '.@each');
      path = path + (path && '.') + split.join('.');

      // Add ourselves as dependants
      root.__computedDeps[path] || (root.__computedDeps[path] = []);
      root.__computedDeps[path].push(this);
    }, this);

    // Ensure we only have one listener per Model at a time.
    context.off('all', this.onRecompute).on('all', this.onRecompute);
  }
function(){
    var root = this.__root__;
    var context = this.__parent__;
    root.__computedDeps || (root.__computedDeps = {});

    _.each(this.deps, function(path){

      // For each dependancy, mark ourselves as dirty if they become dirty
      var dep = root.get(path, {raw: true, isPath: true});
      if(dep && dep.isComputedProperty){ dep.on('dirty', this.markDirty); }

      // Find actual context and path from relative paths
      var split = $.splitPath(path);
      while(split[0] === '@parent'){
        context = context.__parent__;
        split.shift();
      }
      path = context.__path().replace(/\.?\[.*\]/ig, '.@each');
      path = path + (path && '.') + split.join('.');

      // Add ourselves as dependants
      root.__computedDeps[path] || (root.__computedDeps[path] = []);
      root.__computedDeps[path].push(this);
    }, this);

    // Ensure we only have one listener per Model at a time.
    context.off('all', this.onRecompute).on('all', this.onRecompute);
  }
function ( ) { var root = this . __root__ ; var context = this . __parent__ ; root . __computedDeps || ( root . __computedDeps = { } ) ; _ . each ( this . deps , function ( path ) { // For each dependancy, mark ourselves as dirty if they become dirty var dep = root . get ( path , { raw : true , isPath : true } ) ; if ( dep && dep . isComputedProperty ) { dep . on ( 'dirty' , this . markDirty ) ; } // Find actual context and path from relative paths var split = $ . splitPath ( path ) ; while ( split [ 0 ] === '@parent' ) { context = context . __parent__ ; split . shift ( ) ; } path = context . __path ( ) . replace ( / \.?\[.*\] / ig , '.@each' ) ; path = path + ( path && '.' ) + split . join ( '.' ) ; // Add ourselves as dependants root . __computedDeps [ path ] || ( root . __computedDeps [ path ] = [ ] ) ; root . __computedDeps [ path ] . push ( this ) ; } , this ) ; // Ensure we only have one listener per Model at a time. context . off ( 'all' , this . onRecompute ) . on ( 'all' , this . onRecompute ) ; }
Adds a litener to the root object and tells it what properties this Computed Property depend on. The listener will re-compute this Computed Property when any are changed.
Adds a litener to the root object and tells it what properties this Computed Property depend on . The listener will re - compute this Computed Property when any are changed .