Use @memo or @memo() for automatic dependency trapping. Pass a function
only when you want finer cache-key control; the function captures this
lazily, so the values are read fresh each time the getter is accessed.
Cache semantics (matches ReactiveNode.memo):
@memo and @memo() are interchangeable. Both run the
getter under automatic dependency trapping and recompute when one of the
trapped reads changes.undefined: recompute on every reproxy of the ReactiveNode.[]: compute once, cache forever for this instance.[a, b, ...]: recompute on shallow-change.The cache key is the getter's property name, so each @memo-decorated getter has
its own cell automatically.
@memo is a cache, not a subscription. It does not emit Retree events or
trigger React renders by itself. Use ReactiveNode.dependencies,
Retree.select, or useSelect when you also need notification behavior.
Do not use @memo on methods; use fnMemo. Do not use it for values
with side effects.
class ListFilter extends ReactiveNode {
list: Card[] = [];
searchText = "";
@memo
get filteredList() {
return this.list.filter((c) => c.text === this.searchText);
}
get dependencies() { return [this.dependency(this.list)]; }
}
Pass explicit comparisons when the automatic trapper is broader than you want:
@memo((self: ListFilter) => [self.list, self.searchText])
get filteredListWithExplicitComparisons() {
return this.list.filter((c) => c.text === this.searchText);
}
Decorator that memoizes a getter on a ReactiveNode.
OptionalgetComparisons: (self: This) => unknown[] | undefinedUse @memo or @memo() for automatic dependency trapping. Pass a function
only when you want finer cache-key control; the function captures this
lazily, so the values are read fresh each time the getter is accessed.
Cache semantics (matches ReactiveNode.memo):
@memo and @memo() are interchangeable. Both run the
getter under automatic dependency trapping and recompute when one of the
trapped reads changes.undefined: recompute on every reproxy of the ReactiveNode.[]: compute once, cache forever for this instance.[a, b, ...]: recompute on shallow-change.The cache key is the getter's property name, so each @memo-decorated getter has
its own cell automatically.
@memo is a cache, not a subscription. It does not emit Retree events or
trigger React renders by itself. Use ReactiveNode.dependencies,
Retree.select, or useSelect when you also need notification behavior.
Do not use @memo on methods; use fnMemo. Do not use it for values
with side effects.
class ListFilter extends ReactiveNode {
list: Card[] = [];
searchText = "";
@memo
get filteredList() {
return this.list.filter((c) => c.text === this.searchText);
}
get dependencies() { return [this.dependency(this.list)]; }
}
Pass explicit comparisons when the automatic trapper is broader than you want:
@memo((self: ListFilter) => [self.list, self.searchText])
get filteredListWithExplicitComparisons() {
return this.list.filter((c) => c.text === this.searchText);
}
Decorator that memoizes a getter on a ReactiveNode.