-
-
Notifications
You must be signed in to change notification settings - Fork 497
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
Document how to update arrays and objects in Ember Octane #1539
Comments
Sorry the details are a bit fuzzy. Please feel free to reach out to me for questions about what to write. For Hacktoberfest, I think we can split this issue into 2 (one for arrays, and another for objects), to keep the scope small. |
Hi I just stumbled upon this. I tried some approaches and what worked best for me was the replace method:\
I had no luck with Object.assign:
Changes here were not propagated to my view (@Tracked collection). |
I know I'm just randomly weighing in here but having just taken a good look at the docs on autotracking while working on onboarding materials for my team it's fresh on my mind. So my unasked-for 2 cents: I think part of the reason there isn't a clear direction to take these docs in is that it's very dependent on context. The three basic buckets I've seen complex-tracking solutions fall into are the following:
I don't think we should ever recommend using EmberArray/Ember.A (which seems to be what we do now). I think that will just lead to confusion and long-term churn. I know the general idea is to point people in the simplest direction in the guides but that's more difficult here. I suppose the replacement/immutable method would work best for the basic Tracked Properties page, and the other options (and what scenarios they are best for) could be covered on the in-depth topics page. But IMO they should all be covered and it's important to call out when/why you might want to use each one. I think this is an important topic that anyone can get hung up on. Two recent RFCs have slightly clarified the direction this should probably take: So I don't think it makes sense to ever recommend EmberArray as a solution to this, and I think it will be ok to build the guides around tracked-built-ins (at least once they land) since they will actually be built-in. Anyway that's my two cents. Happy to contribute to these pages if there's enough consensus on what direction to go here. |
Background
Description
We currently don't describe well how to update tracked arrays and objects in Ember Octane. On Discord, now and then, a developer does ask how they can do so.
Possible TODOs
1. Arrays
this.myArray.push(...);
.EmberArray
tracked-built-ins
2. Objects
this.myObject.myProperty = ...;
.tracked-built-ins
3. Backport
Once the changes are approved for
release
directory, backport the changes all the way back to Ember 3.15.Questions
The text was updated successfully, but these errors were encountered: