Created
July 25, 2014 16:52
-
-
Save hjdivad/e482c531a5f5a0623726 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function filterBy (dependentKey, propertyKey, filterPropertyName) { | |
var callback; | |
if (arguments.length === 2) { | |
callback = function(item) { | |
return get(item, propertyKey); | |
}; | |
} else { | |
callback = function(item) { | |
return get(item, propertyKey) === get(this, filterPropertyName); | |
}; | |
} | |
var arrayDK = dependentKey + '.@each.' + propertyKey; | |
// Ember.computed.filter | |
return filter(arrayDK, callback).property(arrayDK, filterPropertyName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment