Retree - v1.0.0
    Preparing search index...

    Function memo

    • Decorator that memoizes a getter on a ReactiveNode.

      Type Parameters

      Parameters

      Returns (this: This) => Value

      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):

      • No argument: @memo and @memo() are interchangeable. Both run the getter under automatic dependency trapping and recompute when one of the trapped reads changes.
      • Returns undefined: recompute on every reproxy of the ReactiveNode.
      • Returns []: compute once, cache forever for this instance.
      • Returns [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.

      Type Parameters

      Parameters

      • OptionalgetComparisons: (self: This) => unknown[] | undefined

      Returns <Value>(
          target: (this: This) => Value,
          context: ClassGetterDecoratorContext<This, Value>,
      ) => (this: This) => Value

      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):

      • No argument: @memo and @memo() are interchangeable. Both run the getter under automatic dependency trapping and recompute when one of the trapped reads changes.
      • Returns undefined: recompute on every reproxy of the ReactiveNode.
      • Returns []: compute once, cache forever for this instance.
      • Returns [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);
      }