-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
I'm a long-time Ember user and it wasn't clear to me until recently that getters that use autotracking in Glimmer components are not memoized by default. In my interpretation of all the things that I read about autotracking in annoucements, blog posts and so on, autotracking was a drop-in replacement for computed: all the same benefits (including memoization) but without having to explicitly list the dependencies. Maybe I didn't read carefully enough, or maybe it wasn't communicated clearly enough.
I realized that it wasn't when I started noticing degrading performance when I moved certain components in my application to Ember Octane. To my surprise, many getters were being recomputed even though the values of the getters they call didn't change.
For this reason, I can't wait for the @cached RFC to merge or to be available in a polyfill.
However, in the mean time, I still want to be able to enforce memoization for some properties in my Ember Octane components:
- What is the idiomatic way of doing this in the current version of Ember.js? Is the
@computeddecorator compatible with autotracking? I don't mind if I need to explicitly list dependencies until the @cached RFC is merged. My priority now is to resolve the performance issues by avoiding unnecessary expensive recomputations. - Would it make sense to document this somewhere, in e.g. the Autotracking In-Depth guide? I'd be happy create a PR that adds this once I know the answer to my first question.