emberjs/ember.js — pull request #3707 by hjdivad (2013-11-07 21:22:13+00:00)
Title: [BUGFIX release] Fix #3681.

`Em.arrayComputed` is not presently compatible with lazy CPs. There are a few
issues.

1. To keep refs up to date, observers stay around as long as the object does.
2. Those observers can repopulate the cache, but when they do so they fail to
add dependent keys when the cache was empty.

This commit works around 2. by not removing them in the first place.
Essentially the semantics for `ArrayComputedProperty`s differ from standard
`ComputedProperty`s with regards to laziness.

These observers need to be managed better. Probably the right thing to do,
now that `recomputeOnce` is no longer necessary, is to:
1. Fix `Em.computed.sort` to not use `recomputeOnce`;
2. Fix `Em.arrayComputed` to return a proxy to the cached value;
3. Teardown array observers when the deps count hits 0.

This will give reduce computed properties semantics much closer to regular
computed properties. There are two important points to note about this
suggestion:

1. The cached values would still update synchronously. This can be improved
with a lazy array implementation and @wycats's skiplist strategy.

2. The semantics of an array computed would change such that existing refs
would only be kept up to date as long as the cache had not been invalidated.
This is probably fine: the current behaviour is not promised in the
documentation anywhere and it would be pretty bad practice to keep references
around rather than `Ember.get`ing them.