[CLEANUP beta] Remove deprecated array observers#19833
Merged
mixonic merged 1 commit intoemberjs:masterfrom Nov 12, 2021
Merged
[CLEANUP beta] Remove deprecated array observers#19833mixonic merged 1 commit intoemberjs:masterfrom
mixonic merged 1 commit intoemberjs:masterfrom
Conversation
a5f28d2 to
2430326
Compare
2430326 to
825bf5f
Compare
mixonic
reviewed
Nov 12, 2021
| * Array proxies have a `_revalidate` method which must be called to set | ||
| * up their internal array observation systems. | ||
| */ | ||
| obj._revalidate?.(); |
Member
There was a problem hiding this comment.
In this patch hasArrayObserver has been removed. That property was not directly deprecated in 3.x, however we've removed a number of APIs in this patch which were related to someArray.addArrayObserver (APIs which were only meaningful once you had an observer installed).
Because it is removed, it no longer needs to be notified of change. However the _revalidate hook on ArrayProxy instances was being called via PROPERTY_DID_CHANGE symbol notification. Without trying to rewrite that system we have two options: Either call _revalidate() directly, or keep the property hasArrayObserver around just to trigger the PROPERTY_DID_CHANGE. Here I've chosen to call _revalidate() directly.
ebcf3a1 to
d374744
Compare
Part of emberjs#19617 * Remove `someArray.addArrayObserver` https://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L532 * Remove `someArray.removeArrayObserver` https://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L548 * Remove `someArray.hasArrayObservers` https://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L571 * Remove `someArray.arrayContentWillChange` https://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L642 * Remove `someArray.arrayContentDidChange` https://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L670 (also at https://github.com/emberjs/ember.js/pull/19833/files#diff-79a0015ca0e6a6c3661d9119f4caf6b26b111af6bb0e5bb784558631c599a81cL357) * On the internal version of `addArrayObserver`, remove the optionality of `willChange` and `didChange` arguments to name the hooks. In framework code (and now in test) these are always provided. * Retain basically all the test coverage of array observers since they remain used by `ArrayProxy` internally (and through that interface, in Ember Data). Co-authored-by: Matthew Beale <matt.beale@madhatted.com>
d374744 to
a9aedea
Compare
pzuraq
approved these changes
Nov 12, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #19617
Supplants #19746
someArray.addArrayObserverhttps://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L532someArray.removeArrayObserverhttps://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L548someArray.hasArrayObservershttps://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L571someArray.arrayContentWillChangehttps://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L642someArray.arrayContentDidChangehttps://github.com/emberjs/ember.js/pull/19833/files#diff-8116921433c6e1664250d5735e4f9daeb6ea9e00940783e0c4db7adf88aa8772L670 (also at https://github.com/emberjs/ember.js/pull/19833/files#diff-79a0015ca0e6a6c3661d9119f4caf6b26b111af6bb0e5bb784558631c599a81cL357)addArrayObserver, remove the optionality ofwillChangeanddidChangearguments to name the hooks. In framework code (and now in test) these are always provided.ArrayProxyinternally (and through that interface, in Ember Data).Co-authored-by: Matthew Beale matt.beale@madhatted.com