Skip to content

Ensure did-update only re-runs when arguments change (avoid recomputing when tracked properties update within callback) #54

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

Merged
merged 3 commits into from
Dec 13, 2021

Conversation

mogstad
Copy link
Contributor

@mogstad mogstad commented Nov 17, 2021

Modifier capabillities in 3.22, requires all arguments to be consumed,
to be tracked. This meant disableAutoTracking had to be set to false
for the modifier to work with 3.22 capabillities. This had the
sideeffect that any other consumed tags ended up being tracked. Meaning
the did-update callback was invoked whenever those tags changed.

@mogstad mogstad force-pushed the untrack-did-update-callback branch from a4f7e8a to bc012f7 Compare November 17, 2021 14:48
@SergeAstapov
Copy link
Contributor

SergeAstapov commented Nov 18, 2021

Sorry for introducing this!
For the context, this issue was introduced in #42.

There was same issue in 1.x series originally fixed in #16 (unless I'm missing something).

@boris-petrov
Copy link

Is this fixing the issue I described here by any chance?

@mogstad
Copy link
Contributor Author

mogstad commented Dec 1, 2021

Yes, this patch should fix that!

@@ -1,5 +1,6 @@
import { setModifierManager, capabilities } from '@ember/modifier';
import { gte } from 'ember-compatibility-helpers';
import { untrack } from '@glimmer/validator';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this import will work for ember-source < 3.27, in versions prior to 3.27 these sorts of internal ember modules were hidden and not available for import...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approved the CI run, so we should see those failures (in 3.24 at least)

Copy link
Member

@rwjblue rwjblue Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Ember 3.12 ember-try scenario:

not ok 5 Chrome 96.0 - [38 ms] - Integration | Modifier | did-update: it basically works
    ---
        stack: >
            Error: Could not find module `@glimmer/validator` imported from `@ember/render-modifiers/modifiers/did-update`
                at missingModule (http://localhost:7357/assets/vendor.js:259:11)
                at findModule (http://localhost:7357/assets/vendor.js:270:7)
                at Module.findDeps (http://localhost:7357/assets/vendor.js:180:24)
                at findModule (http://localhost:7357/assets/vendor.js:274:11)
                at Module.findDeps (http://localhost:7357/assets/vendor.js:180:24)
                at findModule (http://localhost:7357/assets/vendor.js:274:11)
                at requireModule (http://localhost:7357/assets/vendor.js:36:15)
                at ModuleRegistry.get (http://localhost:7357/assets/vendor.js:67734:14)
                at Class._extractDefaultExport (http://localhost:7357/assets/vendor.js:68170:41)
                at Class.resolveOther (http://localhost:7357/assets/vendor.js:67830:32)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a commit that should resolve this issue...

Modifier capabillities in 3.22, requires all arguments to be consumed,
to be tracked. This meant `disableAutoTracking` had to be set to `false`
for the modifier to work with 3.22 capabillities. This had the
sideeffect that any other consumed tags ended up being tracked. Meaning
the `did-update` callback was invoked whenever those tags changed.
@rwjblue rwjblue force-pushed the untrack-did-update-callback branch from 57268a9 to 95a3fe5 Compare December 13, 2021 20:53
@@ -27,6 +27,7 @@
"test:ember-compatibility": "ember try:each"
},
"dependencies": {
"@embroider/macros": ">= 0.48.1 < 2.0.0-alpha.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@embroider/macros is "stable", this ensures that we can continually get the most recent version (and don't force an app to end up with a bunch of versions due to our dependency).

@rwjblue rwjblue force-pushed the untrack-did-update-callback branch from 95a3fe5 to 94b3132 Compare December 13, 2021 21:22
@rwjblue rwjblue added the bug Something isn't working label Dec 13, 2021
@rwjblue rwjblue force-pushed the untrack-did-update-callback branch from cf434e3 to 8dd14c7 Compare December 13, 2021 22:06
@rwjblue rwjblue changed the title Run did-update callback in an untracked frame Ensure did-update only re-runs when arguments change (avoid recomputing when tracked properties update within callback) Dec 13, 2021
@rwjblue rwjblue merged commit 88ab231 into emberjs:master Dec 13, 2021
@mogstad mogstad deleted the untrack-did-update-callback branch December 13, 2021 22:46
@ctjhoa ctjhoa mentioned this pull request Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants