-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: did-update
entaglement on Ember 3.23+
#286
Conversation
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.
Thanks for investigating and fixing this! ❤️
addon/helpers/did-update.ts
Outdated
if (!this.didRun) { | ||
this.didRun = true; | ||
positional.forEach(() => {}); | ||
Object.values(named).forEach(() => {}); | ||
return; | ||
} | ||
fn(positional.slice(1), named); |
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.
if (!this.didRun) { | |
this.didRun = true; | |
positional.forEach(() => {}); | |
Object.values(named).forEach(() => {}); | |
return; | |
} | |
fn(positional.slice(1), named); | |
if (!this.didRun) { | |
this.didRun = true; | |
// Consume individual properties to entangle tracking. | |
// https://github.com/emberjs/ember.js/issues/19277 | |
Object.values(positional); | |
Object.values(named); | |
return; | |
} | |
fn(positional.slice(1), named); |
I think just calling Object.values(...)
should be sufficient, as this already triggers the getters for each property.
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.
Do we also need to access positional.length
to support positional.pushObject('new tail')
?
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.
Similarly, would this work when a new key is added to named
via named.set('newKey', true)
?
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.
You don't need to verify these things, if you don't wanna. I'll check this out later today, add tests and migrate the CI setup to GitHub Actions.
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 force-pushed the suggested change. However, I'm not sure about the things you're asking. If you can check them later, that would be great, thanks!
Note that this is a "hack" around (I guess) the Ember bug. If they fix it soon, you could then revert that change.
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.
hm, Object.values
doesn't work on an array:
Object.keys() was called on the positional arguments array for a helper, which is not supported. This function is a low-level function that should not need to be called for positional argument arrays. You may be attempting to iterate over the array using for...in instead of for...of.
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.
Object.values([1, 2, 3])
does work on an array. It's rather that the Ember args proxy apparently has a bug and doesn't support being used with Object.values(positional)
🙈
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.
@buschtoens - I'm not sure when the bug is going to be fixed on Ember's side - do you mind merging this and releasing a new version and later on you can revert it when Ember fixes it?
did-update
recomputation on Ember 3.23+did-update
entaglement on Ember 3.23+
See emberjs/ember.js#19277
Fixes #282
cc @buschtoens