API reference · generated from source
Function: ignore()#
function ignore(_value, context): void | ((this, value) => any);Defined in: decorators.ts:54
Field decorator that excludes a property of a ReactiveNode from Retree's reactivity system.
Parameters#
| Parameter | Type |
|---|---|
_value | undefined |
context | ClassFieldDecoratorContext |
Returns#
void | ((this, value) => any)
Remarks#
Reads and writes to the ignored field still work normally, but:
- The proxy will not wrap the field's value or build child proxies underneath it,
so nested mutations (e.g.
this.ignored.count = 1) do not emitnodeChanged/treeChangedlisteners on the parent. - Replacing the field at the top level (e.g.
this.ignored = {...}) likewise skips listener emission.
Use this for state that lives on a ReactiveNode but should not participate in
the tree — caches, scratch buffers, framework handles, references to objects
already managed elsewhere, etc.
Do not use @ignore when you want a reactive pointer to another node. Use
link or Retree.link for that. Writes to ignored fields do
not emit Retree listeners or React re-renders.
Example#
import { Retree, ReactiveNode, ignore } from "@retreejs/core";
class Counter extends ReactiveNode {
public count = 0;
// Mutations to `cache` do not trigger Retree listeners.
@ignore public cache: Record<string, unknown> = {};
get dependencies() { return []; }
}
const node = Retree.root(new Counter());
Retree.on(node, "nodeChanged", () => console.log("changed"));
node.cache.something = 1; // ❌ no log
node.count = 1; // ✅ logs "changed"