Invocation of getters with ComputedFrom decorator

We’re currently using aurelia in a medium large application and we’re seing our computed properties being executed each time they are being accessed and not only every time their dependencies change.

Is this correct behaviour? I would expect that since we are declaring the dependencies of the getter, we could memoize the function based on the values of the dependencies.

I’m also noticing that the getter functions are invoked the number of times they are called + 1.

Here’s a reproduction:

1 Like

This is probably the same discussion over on github:
Probably same question here:

Seems like it’s not part of the core framework but there exists a plugin for the behaviour:

After some searching I guess the behaviour I was expecting was something more similar to how Ember does it here

1 Like

In v1, we don’t replace the getter decorated witt @computedFrom, that’s why you are seeing this behavior, because it’s not possible to cache without wrapping the getter.
In the plugin you mentioned, the getter is wrapped and it’s able to cache it. In v2, this should also be the default behavior. I’m refactoring a few bits around observation system to enable this.

1 Like