-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs$rootScope.Scope#$watchGroup: clarify listener's oldValues parameter #12643
Conversation
…or watchGroup To avoid confusion like #8671 and #12452 and http://plnkr.co/edit/Ir1X88bRL95mvm7l6f4N?p=preview.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
The most valuable PR ever. And I'm only half-joking)) This was a great source of confusion for me. |
@@ -418,8 +418,9 @@ function $RootScopeProvider() { | |||
* expression in `watchExpressions` changes | |||
* The `newValues` array contains the current values of the `watchExpressions`, with the indexes matching | |||
* those of `watchExpression` | |||
* and the `oldValues` array contains the previous values of the `watchExpressions`, with the indexes matching | |||
* those of `watchExpression` | |||
* and the `oldValues` array contains the value of each `watchExpression` before the last change (it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is clear enough. My head actually hurts a bit reading it. I will also see if I can come up with a better wording.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it is not perfect. It is pretty tricky to describe this behavior concisely and clearly. New attempt:
and the
oldValues
array contains the value of eachwatchExpression
before it was last changed (even if that change did not happen in this digest cycle).
Happy for any suggestion with regards to wording - as long as we mention this for me unexpected behavior explicitly. If you can tell which part exactly find hard to understand, I will try to improve that specifically.
Thanks for the PR, this is important info indeed. I think we should also add an example that shows how the watchGroup executes the listener, and with what values. |
I signed it! |
CLAs look good, thanks! |
This should help to prevent issues such as angular#8671, angular#12452, angular#16004. Closes angular#12643
This should help to prevent issues such as angular#8671, angular#12452, angular#16004. Closes angular#12643
This should help to prevent issues such as angular#8671, angular#12452, angular#16004. Closes angular#12643
Docs have been updated in 06baf18 |
Mention explicitly that oldValues may contain changes that happened before the last call to listener, as this seems non-obvious, see