Skip to content

Instantly share code, notes, and snippets.

@hjdivad
Created July 25, 2014 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjdivad/e482c531a5f5a0623726 to your computer and use it in GitHub Desktop.
Save hjdivad/e482c531a5f5a0623726 to your computer and use it in GitHub Desktop.
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