packages/rebound-data/lib/computed-property.js
function(key, val, options={}){

    if(this.returnType === null){ return void 0; }
    var attrs = key;
    var value = this.value();

    // Noralize the data passed in
    if(this.returnType === 'model'){
      if (typeof key === 'object') {
        attrs = (key.isModel) ? key.attributes : key;
        options = val || {};
      } else {
        (attrs = {})[key] = val;
      }
    }
    if(this.returnType !== 'model'){ options = val || {}; }
    attrs = (attrs && attrs.isComputedProperty) ? attrs.value() : attrs;

    // If a new value, set it and trigger events
    this.setter && this.setter.call(this.__root__, attrs);

    if(this.returnType === 'value' && this.cache.value !== attrs) {
      this.cache.value = attrs;
      if(!options.quiet){
        // If set was called not through computedProperty.call(), this is a fresh new event burst.
        if(!this.isDirty && !this.isChanging) this.__parent__.changed = {};
        this.__parent__.changed[this.name] = attrs;
        this.trigger('change', this.__parent__);
        this.trigger('change:'+this.name, this.__parent__, attrs);
        delete this.__parent__.changed[this.name];
      }
    }
    else if(this.returnType !== 'value' && options.reset){ key = value.reset(attrs, options); }
    else if(this.returnType !== 'value'){ key = value.set(attrs, options); }
    this.isDirty = this.isChanging = false;

    // Call all reamining computed properties waiting for this value to resolve.
    _.each(this.waiting, function(prop){ prop && prop.call(); });

    return key;
  }
function(key, val, options={}){

    if(this.returnType === null){ return void 0; }
    var attrs = key;
    var value = this.value();

    // Noralize the data passed in
    if(this.returnType === 'model'){
      if (typeof key === 'object') {
        attrs = (key.isModel) ? key.attributes : key;
        options = val || {};
      } else {
        (attrs = {})[key] = val;
      }
    }
    if(this.returnType !== 'model'){ options = val || {}; }
    attrs = (attrs && attrs.isComputedProperty) ? attrs.value() : attrs;

    // If a new value, set it and trigger events
    this.setter && this.setter.call(this.__root__, attrs);

    if(this.returnType === 'value' && this.cache.value !== attrs) {
      this.cache.value = attrs;
      if(!options.quiet){
        // If set was called not through computedProperty.call(), this is a fresh new event burst.
        if(!this.isDirty && !this.isChanging) this.__parent__.changed = {};
        this.__parent__.changed[this.name] = attrs;
        this.trigger('change', this.__parent__);
        this.trigger('change:'+this.name, this.__parent__, attrs);
        delete this.__parent__.changed[this.name];
      }
    }
    else if(this.returnType !== 'value' && options.reset){ key = value.reset(attrs, options); }
    else if(this.returnType !== 'value'){ key = value.set(attrs, options); }
    this.isDirty = this.isChanging = false;

    // Call all reamining computed properties waiting for this value to resolve.
    _.each(this.waiting, function(prop){ prop && prop.call(); });

    return key;
  }
function ( key , val , options = { } ) { if ( this . returnType === null ) { return void 0 ; } var attrs = key ; var value = this . value ( ) ; // Noralize the data passed in if ( this . returnType === 'model' ) { if ( typeof key === 'object' ) { attrs = ( key . isModel ) ? key . attributes : key ; options = val || { } ; } else { ( attrs = { } ) [ key ] = val ; } } if ( this . returnType !== 'model' ) { options = val || { } ; } attrs = ( attrs && attrs . isComputedProperty ) ? attrs . value ( ) : attrs ; // If a new value, set it and trigger events this . setter && this . setter . call ( this . __root__ , attrs ) ; if ( this . returnType === 'value' && this . cache . value !== attrs ) { this . cache . value = attrs ; if ( ! options . quiet ) { // If set was called not through computedProperty.call(), this is a fresh new event burst. if ( ! this . isDirty && ! this . isChanging ) this . __parent__ . changed = { } ; this . __parent__ . changed [ this . name ] = attrs ; this . trigger ( 'change' , this . __parent__ ) ; this . trigger ( 'change:' + this . name , this . __parent__ , attrs ) ; delete this . __parent__ . changed [ this . name ] ; } } else if ( this . returnType !== 'value' && options . reset ) { key = value . reset ( attrs , options ) ; } else if ( this . returnType !== 'value' ) { key = value . set ( attrs , options ) ; } this . isDirty = this . isChanging = false ; // Call all reamining computed properties waiting for this value to resolve. _ . each ( this . waiting , function ( prop ) { prop && prop . call ( ) ; } ) ; return key ; }
Set the Computed Property's cache to a new value and trigger appropreate events. Changes will propagate back to the original object if a Rebound Data Object and re-compute. If Computed Property returns a value, all downstream dependancies will re-compute.
Set the Computed Property s cache to a new value and trigger appropreate events . Changes will propagate back to the original object if a Rebound Data Object and re - compute . If Computed Property returns a value all downstream dependancies will re - compute .