# Ember.computed.filterBy question

**URL:** <https://discuss.emberjs.com/t/ember-computed-filterby-question/4288>\
**Category:** Uncategorized\
**Created:** [February 27, 2014, 9:06am UTC](https://discuss.emberjs.com/t/ember-computed-filterby-question/4288 "2014-02-27T09:06:16Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![darkbaby123](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/darkbaby123/32/11360_2.png) [@darkbaby123](https://discuss.emberjs.com/u/darkbaby123)\
**Post date:** [February 27, 2014, 3:20pm UTC](https://discuss.emberjs.com/t/ember-computed-filterby-question/4288/3 "2014-02-27T15:20:59Z")

</div>

The source of `Ember.computed.filter` is [here](https://github.com/emberjs/ember.js/blob/v1.4.0/packages/ember-runtime/lib/computed/reduce_computed_macros.js#L260). As you can see it uses `Ember.arrayComputed`, which updates property with “one at a time” semantics.

What does “one at a time” mean?

Look at the common `property` example:

```javascript
productsPremiumShown: function() {
  return this.get("productsShown").filterBy('is_premium', true);
}.property("productsShown.[]")

```

It means, when the productShown array is changed, the property is **fully recomputed**. Which means running `this.get("productsShown").filterBy('is_premium', true)`.

In this code, everytime the property is changed, it iterates the whole array to get the filtered result.

If we have a way, when a new item is added to productsShown array, the filter function is only executed for that item, if it matches, then add that item to productsPreminumShown array, otherwise do nothing. That should be better.

This is “one at a time” way, and is what `Ember.computed.filter` do for you.

For details you can check [Ember.arrayComputed](http://emberjs.com/api/classes/Ember.html#method_arrayComputed) and [Ember.reduceComputed](http://emberjs.com/api/classes/Ember.html#method_reduceComputed).

Actually, `Ember.computed.filter` is a syntax suger for `Ember.arrayComputed`, and `Ember.arrayComputed` is a syntax suger for `Ember.reduceComputed`. So if you understand `Ember.reduceComputed`, you understand all of them.

---

_[View the full topic](https://discuss.emberjs.com/t/ember-computed-filterby-question/4288)._
