Add tracked properties behind a feature flag #16366
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 pull request adds Glimmer's tracked properties (including autotrack) to Ember, but with better Ember integration.
This PR includes "auto-tracking" of tracked getters, added to Glimmer in glimmerjs/glimmer.js#115.
For context, here is the description of the PR when added to Glimmer:
This PR also integrates tracked properties with Ember's object model.
Concretely, this means:
In practice, this means that it is possible to migrate an Ember-style object to an idiomatic Glimmer-style object, and computed properties that consume the Glimmer-style object will work without adding new dependent keys.
There are still an open question about how to usefully tell developers when they have forgotten to mark properties as tracked (
.set()
gives us an opportunity to notice when an object was mutated without being properly marked, but it's harder to track when the mistake is just mutating a regular JavaScript object.There is some evidence that it's possible to explain the programming model where forgetting to do something explicit means values won't update (silently) from other communities, but:
One thing we've considered is using the existing development-mode proxy we create for Ember-style objects to detect patterns where a property on an Ember object was consumed inside of a computed property or tracked getter and later set, so we could tell the user where they have forgotten to add the tracked annotation. This is a speculative idea that may not pan out, and resolving this open question is important before stabilizing this feature.