Can code access memoized property values from direct JS calls?

consider this class:

class Person {
  @tracked mother;
  @tracked father;

  @readOnly('mother.father') maternalGrampa;

  get paternalGrampa() {
    return father && this.father.father;

  get hasAtLeastOneGrampa() {
    return Boolean(this.maternalGrampa || this.paternalGrampa);

If a template binds to hasAtLeastOneGrampa, then as I understand it, hasAtLeastOneGrampa will not be reevaluated as long as neither grampa has changed. However, if JS code calls hasAtLeastOneGrampa directly, then the evaluation will reoccur, which is different than if JS calls maternalGrampa - that code will receive a memoized result provided mother.father has not changed.

My question is - without having to add @computed('maternalGrampa', 'paternalGrampa') to hasAtLeastOneGrampa, which kind of defeats the value of auto-tracking, is there a way to have direct JS reads of properties also receive the memoized value? If hasAtLeastOneGrampa is expensive computationally, then it can be very inefficient to reevaluate.

The place where this becomes problematic is where several other properties (which themselves may be template-bound) use this property as an input. When the template renders, if 10 other template-bound properties use this property, then this property is evaluated 10 times even if it does not change value across all 10 calls.

(edited to remove incorrect workaround)

Turns out this is Ember RFC 566 which has a polyfill that was just released: ember-cached-decorator-polyfill

(and for the record, the @readOnly approach above does not work - so this polyfill or something like it is definitely necessary)

“as you were” :slight_smile: