emberjs/ember.js — pull request #3614 by hjdivad (2013-10-18 21:30:12+00:00)
Title: [BUGFIX beta] reduceComputed supports non-array dependencies.

`ReduceComputedProperty`s want 3 kinds of dependencies.

1. non-array dependencies 2. array dependencies with normal (total
invalidation) CP semantics 3. array dependencies with one-at-a-time semantics

It was previously only possible to create `reduceComputed`s with 3. Macros
could be written that would manually handle 1. and 2. For example,
`Ember.computed.sort` does this.

This commit makes possible all three cases.

```js Ember.Object.extend({
nonArray: 'string',
totallyInvalidatingArray: [],
oneAtATimeArray: [],

computed: Ember.reduceComputed( 'nonArray',
'totallyInvalidatingArray.[]',
'oneAtATimeArray', {
addedItem: function () { /* ... */ },
removedItem: function () { /* ... */ }
});
})
```

Arrays whose individual mutations should completely invalidate a
`reduceComputed` are specified by adding the `.[]` suffix to the dependent
key. Note that the items for this array are never passed to the `addedItem`
and
`removedItem` callbacks: they should be treated much like non-array
properties.

A straightforward motivating example is `Ember.computed.sort` - the items to
be sorted should be handled one-at-a-time, but the properties to sort by
should require a complete resort.

Fix #3600.