Skip to content

Commit 912cbdd

Browse files
btellespetebacondarwin
authored andcommitted
docs($rootScope): explain why watchExpression should be idempotent
This attempts to clarify the rationale. The previous sentence was a bit ambiguous. Closes angular#9963
1 parent 0202663 commit 912cbdd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ng/rootScope.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ function $RootScopeProvider() {
253253
* Registers a `listener` callback to be executed whenever the `watchExpression` changes.
254254
*
255255
* - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest
256-
* $digest()} and should return the value that will be watched. (Since
257-
* {@link ng.$rootScope.Scope#$digest $digest()} reruns when it detects changes the
258-
* `watchExpression` can execute multiple times per
259-
* {@link ng.$rootScope.Scope#$digest $digest()} and should be idempotent.)
256+
* $digest()} and should return the value that will be watched. (`watchExpression` should not change
257+
* its value when executed multiple times with the same input because it may be executed multiple
258+
* times by {@link ng.$rootScope.Scope#$digest $digest()}. That is, `watchExpression` should be
259+
* [idempotent](http://en.wikipedia.org/wiki/Idempotence).
260260
* - The `listener` is called only when the value from the current `watchExpression` and the
261261
* previous call to `watchExpression` are not equal (with the exception of the initial run,
262262
* see below). Inequality is determined according to reference inequality,

0 commit comments

Comments
 (0)