Skip to content

Instantly share code, notes, and snippets.

@averydev
Created December 23, 2016 00:10
Show Gist options
  • Save averydev/9b7927dd434481a519c968eb298e47ac to your computer and use it in GitHub Desktop.
Save averydev/9b7927dd434481a519c968eb298e47ac to your computer and use it in GitHub Desktop.
How can this be refactored?
//controller
filtered: Ember.computed('filterFn', function (){
return this.get('filterFn')(this.get('allProducts'))
},
actions:{
updateFilter: function (newFilterFn){
this.set('filterFn', newFilterFn)
}
//template
{{filter-component
updateFilter=(action 'updateFilter')
}}
//Component Js
onUpdateFilter: Ember.observer('propertyA', 'propertyB', 'propertyC', function (){
var newFilterMethod = //...construct filtering method based on properties
this.get('updateFilter')(newFilterMethod)
});
@averydev
Copy link
Author

The only idea I have is to put an action="updateFilter" on="change" on every input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment