-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Consume array access to autotrack hasMany #7330
Conversation
Performance Report for a92c2aa Relationship Analysis
|
Asset Size Report for a92c2aa IE11 Builds The size of the library EmberData has increased by 93.0 B (29.0 B compressed) which exceeds the failure threshold of 15 bytes.WarningsThe uncompressed size of the package @ember-data/model has increased by 93.0 B. Changeset
Full Asset Analysis (IE11)
Modern Builds The size of the library EmberData has increased by 93.0 B (29.0 B compressed) which exceeds the failure threshold of 15 bytes.WarningsThe uncompressed size of the package @ember-data/model has increased by 93.0 B. Changeset
Full Asset Analysis (Modern)
Modern Builds (No Rollup) EmberData increased by 93.0 B uncompressed but decreased by 0.0 B compressedWarningsThe uncompressed size of the package @ember-data/model has increased by 93.0 B. Changeset
Full Asset Analysis (Modern)
|
@@ -166,6 +166,13 @@ export default EmberObject.extend(MutableArray, DeprecatedEvented, { | |||
return false; | |||
}, | |||
|
|||
toArray() { | |||
// By using `get()`, the tracking system knows to pay attention to changes that occur. | |||
get(this, '[]'); |
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.
@pzuraq 👋 I'm noticing we have to consume every time it is accessed. Caching on this
once when accessed and preventing further consuming doesn't pass the tests I added here.
I'm thinking this might be expected since sortBy
(through toArray
&& map
) returns a new array each time. What do you think?
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.
Discussed this in the data meeting but wanted to note it down here, the issue is that length
also needs to be instrumented here, along with objectAt
. This because objectAt
is not used when the length is 0, but length is read to check that.
dd9a47a
to
6aa7887
Compare
// By using `get()`, the tracking system knows to pay attention to changes that occur. | ||
get(this, '[]'); | ||
|
||
if (typeof this._length === 'number') { |
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.
Why do we need this check? Should we set the length in init rather than have to do this every time you access length?
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.
Either works! I did that but then thought I would keep all the logic in one place. I can do it in init if you would like!
f2cf8bf
to
7880de8
Compare
7880de8
to
a92c2aa
Compare
Hi everyone, seems like this is ready to go, no? Really sorry for the pressure, but this bug is really making it hard to debug tracking bugs on my update to autotracking. Thanks again! :) |
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.
Can you drop the second commit here, and we can land this (for release in [email protected])?
cb4ba29
to
a92c2aa
Compare
This comment has been minimized.
This comment has been minimized.
[BUG]: Consume array access to autotrack hasMany
close #7311 emberjs/ember.js#19101 #7328 emberjs/ember.js#19139
ref emberjs/ember.js#19105 #7281
Another related autotracking fix for
errorsFor
#7273In this PR
Has Many Arrays implement the Mutable Array mixin. We need to instrument
length
andobjectAt
in order to ensure autotracking works.To do
Follow up: convert to class based && ts file