Function

dependentKey
String
propertyKey
String
value
*
returns
ComputedProperty
the filtered array

Filters the array by the property and value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { filterBy } from '@ember/object/computed';
import EmberObject from '@ember/object';

let Hamster = EmberObject.extend({
  remainingChores: filterBy('chores', 'done', false)
});

let hamster = Hamster.create({
  chores: [
    { name: 'cook', done: true },
    { name: 'clean', done: true },
    { name: 'write more unit tests', done: false }
  ]
});

hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }]