Created
November 15, 2014 17:42
-
-
Save patricklx/f724c080cd6843d223df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a_slice = [].slice; | |
Ember.ComputedProperty.prototype.chain = function(method){ | |
var chainedCP, dependentKey, args, func, cp = this; | |
dependentKey = Ember.guidFor(cp) + '-chain'; | |
args = [dependentKey].concat(a_slice.call(arguments,1)); | |
if (typeof method === 'string') { | |
method = Ember.computed[method]; | |
} | |
chainedCP = method.apply(null,args); | |
func = chainedCP.func; | |
chainedCP.func = function (propertyName) { | |
if (!this.__ember_meta__.cacheMeta[propertyName+'-chain']) { | |
defineProperty(this, dependentKey, cp); | |
this.__ember_meta__.cacheMeta[propertyName+'-chain'] = true; | |
} | |
return func.apply(this, arguments); | |
}; | |
return chainedCP; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment