Skip to content
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

Requires dependentKeyCompat for consumption by computed properties #112

Open
runspired opened this issue Oct 28, 2021 · 1 comment
Open

Comments

@runspired
Copy link
Contributor

If creating a cached property that is only consumed by one computed property (e.g. nothing else would cause it to recompute), specifying that property as a dependent key requires that the property be defined with both cached and dependentKeyCompat for it to work properly, like so:

import { cached, tracked } from "@glimmer/tracking";
import { dependentKeyCompat } from "@ember/object/compat";

class Foo {
  @tracked biz;


  @cached
  @dependentKeyCompat
  get bar() { return this.biz; }
}
@chriskrycho
Copy link
Contributor

chriskrycho commented Oct 28, 2021

This is expected—but likely worth documenting somewhere.

For other folks who hit this: any getter which only interacts with the auto-tracking system (which includes getters using @cached) will require @dependentKeyCompat for downstream computed properties to be updated: it's a necessary bridge between the "pull"-based system of Octane/auto-tracking, where everything between a tracked property and the reactivity layer (mostly templates) is totally ignorant of the reactivity in general, and the "push" based system (where we actively notified subscribers, who were also actively caching their dependent keys' values).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants