cibernox/ember.js — pull request #1 by cibernox (2014-08-17 09:01:38+00:00)
Title: [FEATURE] Add `invalidate` hook to array/reduce computed

The goal of this PR is to finish (this issue)[https://github.com/emberjs/ember.js/pull/4747] I started some months ago but I never managed to finish.

In a nutshell. When a reduceComputed/arrayComputed property depended on non-array properties and they change, the property get reset and calculated from scratch, which is bad.

To avoid this, an `invalidate` hook can be passed to the property. If defined, it will contain a better way of handle changes in non-array properties other than reset and start from over.

Classical use case:
Filter among many thousands of bank transactions sorted by date those that are within a startDate and endDate. Since they are sorted, when we change the endDate to be more in the future, we can just start by the last transaction accepted and iterate through the next ones until we find the first one that is beyond the endDate (since they are sorted, next ones will be beyond the endDate too).