Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

RELEASE: Add BREAKING CHANGE message to 1.7 changelog #16514

Closed
jbedard opened this issue Mar 28, 2018 · 1 comment
Closed

RELEASE: Add BREAKING CHANGE message to 1.7 changelog #16514

jbedard opened this issue Mar 28, 2018 · 1 comment
Milestone

Comments

@jbedard
Copy link
Collaborator

jbedard commented Mar 28, 2018

See #16494 for the message. See c2b8fab for the commit with the BC.

@Narretz
Copy link
Contributor

Narretz commented Apr 3, 2018

This is the BC message:


BREAKING CHANGE:

(caused by c2b8fab)

Previously when using `$watchGroup` the entries in `newValues` and
`oldValues` represented the *most recent change of each entry*.

Now the entries in `oldValues` will always equal the `newValues` of the previous
call of the listener. This means comparing the entries in `newValues` and
`oldValues` can be used to determine which individual expressions changed.

For example `$scope.$watchGroup(['a', 'b'], fn)` would previously:

|  Action  |  newValue  |  oldValue  |
|----------|------------|------------|
|  (init)  | [undefined, undefined] | [undefined, undefined] |
|  `a=1`   | [1, undefined] | [undefined, undefined] |
|  `a=2`   | [2, undefined] | [1, undefined] |
|  `b=3`   | [2, 3] | [1, undefined] |

Now the `oldValue` will always equal the previous `newValue`:

|  Action  |  newValue  |  oldValue  |
|----------|------------|------------|
|  (init)  | [undefined, undefined] | [undefined, undefined] |
|  `a=1`   | [1, undefined] | [undefined, undefined] |
|  `a=2`   | [2, undefined] | [1, undefined] |
|  `b=3`   | [2, 3] | [2, undefined] |

Note the last call now shows `a === 2` in the `oldValues` array.

This also makes the `oldValue` of one-time watchers more clear. Previously
the `oldValue` of a one-time watcher would remain `undefined` forever. For
example `$scope.$watchGroup(['a', '::b'], fn)` would previously:

|  Action  |  newValue  |  oldValue  |
|----------|------------|------------|
|  (init)  | [undefined, undefined] | [undefined, undefined] |
|  `a=1`   | [1, undefined] | [undefined, undefined] |
|  `b=2`   | [1, 2] | [undefined, undefined] |
|  `a=b=3` | [3, 2] | [1, undefined] |

Where now the `oldValue` will always equal the previous `newValue`:

|  Action  |  newValue  |  oldValue  |
|----------|------------|------------|
|  (init)  | [undefined, undefined] | [undefined, undefined] |
|  `a=1`   | [1, undefined] | [undefined, undefined] |
|  `b=2`   | [1, 2] | [1, undefined] |
|  `a=b=3` | [3, 2] | [1, 2] |

Narretz added a commit to Narretz/angular.js that referenced this issue Apr 11, 2018
Narretz added a commit to Narretz/angular.js that referenced this issue Apr 12, 2018
Narretz added a commit to Narretz/angular.js that referenced this issue Apr 13, 2018
Narretz added a commit to Narretz/angular.js that referenced this issue Apr 13, 2018
Narretz added a commit to Narretz/angular.js that referenced this issue Apr 19, 2018
Narretz added a commit to Narretz/angular.js that referenced this issue Apr 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants