[v2] Use @tracked underneath on Ember 3.16+ #354
Merged
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.
This is a PR to use
@tracked
forTask
andTaskInstance
state on Ember 3.16+ to enable use without using@computed
when consuming derived state.In Ember < 3.16, e-c behaves as it currently does requiring
@computed
to track task-derived state changes.This PR essentially replaces the state properties on the Ember implementations of
Task
andTaskInstance
with those properties decorated with@tracked
(done dynamically, though w/ property descriptors. not redefining them with actual decorator syntax, so there's no dependency on decorator transforms.) This incurs a little bit of a cost, since it's redefining the properties, but practically shouldn't have much effect since it's applied to theTask
andTaskInstance
prototypes, rather than every instance, so it would only be incurred once.There's a few outstanding issues/open questions with this:TheFixedno-render-breaking
tests are triggering re-render assertions (one of them might technically be a "correct" failure.)Seems thatsetProperties
reads the properties it sets, consuming the tag and leading to the error when setting@tracked
properties. I think this can be worked around by usingObject.assign
instead.Tracked internally asperformCount
needs to be read to be updated. Seems this is fine in some contexts, but not others? (i.e. not in the case in one of the tests)_performCount
and used for reads to ensure write-only to trackedperformCount
How does this work for add-ons that depend on ember-concurrency and support multiple Ember versions?@computed
if they consume ember-concurrency state and support < 3.16. However,@computed
Just Works™ with the tracked state, it seems.Within applications with both tracked & computed properties, if using a native getter to access task state, and wishing to use it alongside a computed property,
@dependantKeyCompat
will need to be used on the getter as expected with any other tracked-prop using getter.I'd expect there are probably other edge-cases with this as well.
Resolves #343