-
Notifications
You must be signed in to change notification settings - Fork 75
Autotrack, take 2 #115
Autotrack, take 2 #115
Conversation
The code looks good to me. I've also written a benchmark here: The results are great! There's basically no difference between |
Yay 😍 |
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.
Implementation looks 👌 to me. @wycats, would you mind updating the comments and inline documentation to reflect the code changes? Happy to merge after that's done.
Also, ideally, would you mind updating the body of the PR to explain to viewers at home what's going on here? |
@tomdale done! |
Out of curiosity, would this work too? 😄 class {
first: '',
last: '',
@tracked get name() {
return `${this.first} ${this.last}`;
}
} In other words, is it enough to tell the computed property that it's tracked, or must all dependent keys be marked as tracked too? |
Anything not tracked is considered "constant", so in the above if you expect to update on changes from |
This PR adds "auto-tracking" to tracked getters.
Previously, when defining a tracked computed property, you would write:
After this change, you can leave off the "dependent keys" and write:
Rather than rely on knowing the full list of dependent properties up front, after this change Glimmer tracks the consumption of all
@tracked
properties inside the getter, and automatically creates a validator based on the consumed keys.