Apparently array.filterBy
creates a new array based on the filtered content, whether Ember.Computed.filterBy
reuses the same array.
This difference can be very important when you display a filtered list with {{each}}
helper.
For eaxample, if you define the propery like this:
filteredArray: function(){
return this.get('content').filterBy('isDone', false);
}.property('[email protected]')
The whole {{each}}
block will be rerendered every time the isDone
flag of any record is changed.
If you use Ember.computed
instead, the only changed records will be rerendered:
filteredComputed: Ember.computed.filterBy('content','isDone', false)
Here is a quick example : http://jsbin.com/uHOvANoJ/7/edit?html,js,console,output