-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
DEV: Introduce @dedupeTracked
#27084
Conversation
7f322f3
to
623e273
Compare
Same as `@tracked`, but skips notifying consumers if the value is unchanged. This introduces some performance overhead, so should only be used where excessive downstream re-evaluations are a problem. This is loosely based on `@dedupeTracked` in the `tracked-toolbox` package, but without the added complexity of a customizable 'comparator'. Implementing ourselves also avoids the need for pulling in the entire package, which contains some tools which we don't want, or which are now implemented in Ember/Glimmer (e.g. `@cached`).
623e273
to
2f397ab
Compare
await render(<template> | ||
<span id="initials">{{pet.initials}}</span> | ||
</template>); | ||
|
||
assert.dom("#initials").hasText("SD", "Initials are correct"); |
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.
is rendering a template necessary to this test? 😃
await render(<template> | |
<span id="initials">{{pet.initials}}</span> | |
</template>); | |
assert.dom("#initials").hasText("SD", "Initials are correct"); | |
assert.strictEqual(pet.initials, "SD", "Initials are correct"); |
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.
Hmm... we need some way to know whether downstream autotracking is being notified of a change. Rendering is one way to do that. But perhaps we get the same effect by using @cached
on the getter. Lemme try 👀
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.
Ok that's much cleaner with @cached
. Thanks @CvX!
8a412ec
to
81f6958
Compare
Same as `@tracked`, but skips notifying consumers if the value is unchanged. This introduces some performance overhead, so should only be used where excessive downstream re-evaluations are a problem. This is loosely based on `@dedupeTracked` in the `tracked-toolbox` package, but without the added complexity of a customizable 'comparator'. Implementing ourselves also avoids the need for pulling in the entire package, which contains some tools which we don't want, or which are now implemented in Ember/Glimmer (e.g. `@cached`).
Same as
@tracked
, but skips notifying consumers if the value is unchanged. This introduces some performance overhead, so should only be used where excessive downstream re-evaluations are a problem.This is loosely based on
@dedupeTracked
in thetracked-toolbox
package, but without the added complexity of a customizable 'comparator'. Implementing ourselves also avoids the need for pulling in the entire package, which contains some tools which we don't want, or which are now implemented in Ember/Glimmer (e.g.@cached
).