Allow multiple dependent keys for reduceComputed macros


I’m using the Ember.computed.filter macro to filter a list of objects by a query field (called filterQuery):

filteredContacts: Ember.computed.filter "@this", (contact)->
  ~contact.get('name').toUpperCase().indexOf @get("filterQuery").toUpperCase()

However, if filterQuery changes, it won’t cause the computed array to recompute.

I noticed that custom defined arrayComputed and reduceComputed macros allow for multiple dependent keys, but most of the built-in macros just allow for one. Is there a reason for this? It feels dirty to define a mostly an identical custom filter macro just so I can have additional dependent keys.

I propose to modify the built-in macros to handle multiple dependent keys.


I ran into this not too long ago, and I got around it by calling .property() again. Calling it a second time overrides the dependent keys set the first time. So to get what you want, call .property('@this', 'filterQuery') on the value returned by Ember.computed.filter.