This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Do not call reaction functions with stale values #1113
Open
Description
@tbosch identified this issue in Angular 2.0 / watchtower.js.
Since we batch reaction functions, we may be calling reaction functions with stale values. This leads to unnecessary digests, or in the worst case, infinite (bounded by TTL) loops.
Instead, during the reaction phase, immediately before calling the reaction function, we should recompute the value. If the value has changed back to the old value, do not call the reaction function.
As part of this change, we should add an intermediate "assert" change which counts the number of times this situation occurs. We can run this assert in apps to understand the impact of this change.
cc @mhevery