From 766d85fb9124fc649726777ef2cc7b1865e3afd2 Mon Sep 17 00:00:00 2001 From: Bernie Telles Date: Fri, 7 Nov 2014 13:46:52 -0800 Subject: [PATCH 1/2] Why should watchExpression should be idempotent? This attempts to clarify the rationale. The Previous sentence was a bit ambiguous. If this new explanation does not reflect the intent, please use its active voice (as opposed to passive voice) as a template to clarify the existing sentence. --- src/ng/rootScope.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 43217c37999..5d393aa475c 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -250,9 +250,8 @@ function $RootScopeProvider() { * Registers a `listener` callback to be executed whenever the `watchExpression` changes. * * - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest - * $digest()} and should return the value that will be watched. (Since - * {@link ng.$rootScope.Scope#$digest $digest()} reruns when it detects changes the - * `watchExpression` can execute multiple times per + * $digest()} and should return the value that will be watched. (`watchExpression` should be idempontent + * because it may be executed multiple times per {@link ng.$rootScope.Scope#$digest $digest()}. * {@link ng.$rootScope.Scope#$digest $digest()} and should be idempotent.) * - The `listener` is called only when the value from the current `watchExpression` and the * previous call to `watchExpression` are not equal (with the exception of the initial run, From bef5aaddd85700eee4975193f809584a55c11db7 Mon Sep 17 00:00:00 2001 From: Bernie Telles Date: Thu, 13 Nov 2014 21:10:53 -0800 Subject: [PATCH 2/2] Update rootScope.js Update description. --- src/ng/rootScope.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 5d393aa475c..35ef0a84d91 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -250,9 +250,10 @@ function $RootScopeProvider() { * Registers a `listener` callback to be executed whenever the `watchExpression` changes. * * - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest - * $digest()} and should return the value that will be watched. (`watchExpression` should be idempontent - * because it may be executed multiple times per {@link ng.$rootScope.Scope#$digest $digest()}. - * {@link ng.$rootScope.Scope#$digest $digest()} and should be idempotent.) + * $digest()} and should return the value that will be watched. (`watchExpression` should not change + * its value when executed multiple times with the same input because it may be executed multiple + * times by {@link ng.$rootScope.Scope#$digest $digest()}. That is, `watchExpression` should be + * [idempotent](http://en.wikipedia.org/wiki/Idempotence). * - The `listener` is called only when the value from the current `watchExpression` and the * previous call to `watchExpression` are not equal (with the exception of the initial run, * see below). Inequality is determined according to reference inequality,