API reference · generated from source
Read the guide →Abstract Class: ConvexNode#
Defined in: retree-convex/src/ConvexNode.ts:52
Base class for Retree nodes that need access to a Convex client.
Remarks#
Extend this when a Retree app state node should own live Convex query nodes, paginated query nodes, action/mutation helpers, one-off queries, or connection state. Use BaseConvexNode when you only need imperative actions, mutations, or one-off queries.
Query nodes emit through Retree when Convex sends new values. Actions,
mutations, and queryOnce do not emit unless their results are written into
Retree state or paired with an optimistic update.
Example#
class TasksState extends ConvexNode {
public readonly tasks: ConvexQueryNode<typeof api.tasks.list>;
constructor(client: IConvexClient) {
super(client);
this.tasks = this.query(api.tasks.list);
}
get dependencies() {
return [];
}
}Extends#
Constructors#
Constructor#
new ConvexNode(client): ConvexNode;Defined in: retree-convex/src/ConvexNode.ts:61
Create a Convex-backed Retree node.
Parameters#
| Parameter | Type | Description |
|---|---|---|
client | IConvexClient | Convex client used by this node. |
Returns#
ConvexNode
Overrides#
Properties#
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
client | readonly | IConvexClient | Convex client used by this node. | BaseConvexNode.client | retree-convex/src/BaseConvexNode.ts:53 |
options | public | IRetreeNodeOptions | Runtime options for this Retree node. Remarks Retree ignores this field for reactivity so options do not emit or become part of the tree. | BaseConvexNode.options | retree-core/bin/ReactiveNode.d.ts:138 |
RETREE_LINKED_KEYS_SYMBOL | public | Set<string | symbol> | - | BaseConvexNode.RETREE_LINKED_KEYS_SYMBOL | retree-core/bin/ReactiveNode.d.ts:130 |
RETREE_SELECT_GETTERS_SYMBOL | public | Map<string | symbol, IReactiveSelectGetter<ReactiveNode, unknown>> | - | BaseConvexNode.RETREE_SELECT_GETTERS_SYMBOL | retree-core/bin/ReactiveNode.d.ts:131 |
Accessors#
dependencies#
Get Signature#
get abstract dependencies(): ReactiveNodeDependency[];Defined in: retree-core/bin/ReactiveNode.d.ts:328
Dependencies to listen for changes to.
Remarks
When any IReactiveDependency criteria is met, a change will be emitted for this ReactiveNode instance.
Keep this getter deterministic. Do not start subscriptions, perform network work, or mutate state here. Use ReactiveNode.onObserved, ReactiveNode.onUnobserved, and ReactiveNode.onChanged for lifecycle work.
The returned array may change length or ordering while the node is
observed. Retree treats added, removed, or reordered entries as
invalidation and refreshes subscriptions. Use null when you want an
inactive slot to keep its position, but it is not required for
correctness.
Example
class ProjectSummary extends ReactiveNode {
public tasks: { done: boolean }[] = [];
get doneCount() {
return this.tasks.filter((task) => task.done).length;
}
get dependencies() {
return [this.dependency(this.tasks, [this.doneCount])];
}
}Returns
ReactiveNodeDependency[]
Inherited from#
Methods#
action()#
protected action<Action>(action): RetreeConvexAction<Action>;Defined in: retree-convex/src/BaseConvexNode.ts:119
Create a typed action function bound to this node's Convex client.
Type Parameters#
| Type Parameter |
|---|
Action extends ActionReference |
Parameters#
| Parameter | Type | Description |
|---|---|---|
action | Action | Convex action function reference. |
Returns#
RetreeConvexAction<Action>
A typed action function.
Remarks#
Actions are imperative calls. They do not emit Retree changes unless you write their result into a Retree-managed field.
Example#
const generateSummary = this.action(api.ai.generateSummary);
const summary = await generateSummary({ taskId });
this.summary = summary; // ✅ this write emits if `summary` is reactive stateInherited from#
connectionState()#
protected connectionState(): ConvexConnectionStateNode;Defined in: retree-convex/src/ConvexNode.ts:174
Create a node that tracks this Convex client's connection state.
Returns#
A ConvexConnectionStateNode subscribed with this node's Convex client.
Remarks#
Use this when UI needs to render connection or sync status. Dispose the returned node when its owner is torn down.
Example#
class AppState extends ConvexNode {
public readonly connection: ConvexConnectionStateNode;
constructor(client: IConvexClient) {
super(client);
this.connection = this.connectionState();
}
get dependencies() {
return [];
}
}dependency()#
Call Signature#
dependency<TNode>(node, comparisons?): IReactiveDependency<TNode>;Defined in: retree-core/bin/ReactiveNode.d.ts:441
Creates a new IReactiveDependency instance.
Type Parameters
| Type Parameter | Default type |
|---|---|
TNode extends object | object |
Parameters
| Parameter | Type | Description |
|---|---|---|
node | OptionalNode<TNode> | the node to listen to "nodeChanged" events for. |
comparisons? | any[] | Optional. Values to compare between updates to node. |
Returns
IReactiveDependency<TNode>
dependency object.
Remarks
Use this inside the ReactiveNode.dependencies getter or an
@select dependency selector when one slot needs explicit comparison
cells. If node is a Retree-managed object, it is observed with
nodeChanged. If node is a primitive or unproxied value, Retree
treats it as a comparison-only dependency.
Comparison cells should be deterministic. If their length/order changes,
Retree treats that as invalidation and emits for this node. If no
comparisons are provided, every nodeChanged event from the dependency
emits for this node.
Example
get dependencies() {
return [
this.authStore,
this.authStore.session?.userId,
this.dependency(this.selectedProject ?? null, [this.projectId]),
];
}Inherited from
Call Signature#
dependency<TValue>(value): IReactiveDependency;Defined in: retree-core/bin/ReactiveNode.d.ts:442
Creates a new IReactiveDependency instance.
Type Parameters
| Type Parameter |
|---|
TValue |
Parameters
| Parameter | Type |
|---|---|
value | TValue |
Returns
IReactiveDependency
dependency object.
Remarks
Use this inside the ReactiveNode.dependencies getter or an
@select dependency selector when one slot needs explicit comparison
cells. If node is a Retree-managed object, it is observed with
nodeChanged. If node is a primitive or unproxied value, Retree
treats it as a comparison-only dependency.
Comparison cells should be deterministic. If their length/order changes,
Retree treats that as invalidation and emits for this node. If no
comparisons are provided, every nodeChanged event from the dependency
emits for this node.
Example
get dependencies() {
return [
this.authStore,
this.authStore.session?.userId,
this.dependency(this.selectedProject ?? null, [this.projectId]),
];
}Inherited from
dispose()#
dispose(): void;Defined in: retree-convex/src/ConvexNode.ts:186
Stop live Convex children created by this node.
Returns#
void
Remarks#
React integrations usually do not need to call this directly. Retree runs
it automatically when the ConvexNode loses its final active observer.
Calling it manually is still useful for non-React app shutdown.
link()#
link<TNode>(node): RetreeLink<TNode>;Defined in: retree-core/bin/ReactiveNode.d.ts:204
Create a reactive pointer to an existing Retree-managed node.
Type Parameters#
| Type Parameter |
|---|
TNode extends object |
Parameters#
| Parameter | Type | Description |
|---|---|---|
node | TNode | Existing Retree-managed node to point at. |
Returns#
RetreeLink<TNode>
A Retree-managed RetreeLink whose current points at node.
Remarks#
This is a convenience wrapper around Retree.link. Use it when a
ReactiveNode method needs to return or store a pointer to a node owned
elsewhere without reparenting that node.
Do not use link when ownership should move; use Retree.move or
ReactiveNode.moveTo. Do not use it when two locations need
independent state; use Retree.clone.
Example#
class EditorState extends ReactiveNode {
public selected = null as RetreeLink<Task> | null;
get dependencies() {
return [];
}
public select(task: Task) {
this.selected = this.link(task);
}
}Inherited from#
memo()#
Call Signature#
protected memo<T>(fn, comparisons?): T;Defined in: retree-core/bin/ReactiveNode.d.ts:518
Memoize the result of fn, scoped to this ReactiveNode instance.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
fn | () => T |
comparisons? | unknown[] |
Returns
T
Remarks
Two forms:
- Keyless (inside a getter):
this.memo(fn, deps?)— derives the cache key from the active getter's property name. Throws if called outside a getter or more than once in the same getter. - Explicit key:
this.memo(key, fn, deps?)— works anywhere; required when stacking multiple memo cells in one getter, or memoizing inside a method.
Cache semantics for comparisons:
- Omitted/
undefined: runfnunder automatic dependency trapping and recompute when one of the trapped reads changes. []: compute once and cache forever for this instance.[a, b, ...]: recompute when any cell shallow-changes usingObject.is. Tree-node cells are compared by their latest reproxy identity, so passingthis.listcorrectly invalidates whenlistmutates.
memo is a cache, not a subscription. It does not emit
nodeChanged or trigger React renders by itself. Pair it with
dependencies, Retree.select, or useSelect when you also need
notification behavior.
Example
class ListFilter extends ReactiveNode {
list: Card[] = [];
searchText = "";
// Keyless form
get filteredList() {
return this.memo(
() => this.list.filter((c) => c.text === this.searchText),
[this.list, this.searchText]
);
}
// Explicit-key form (e.g. when stacking two memos in one getter)
get pair() {
const a = this.memo("a", () => expensiveA(), [this.list]);
const b = this.memo("b", () => expensiveB(), [this.searchText]);
return { a, b };
}
get dependencies() { return [this.dependency(this.list)]; }
}Inherited from
Call Signature#
protected memo<T>(
key,
fn,
comparisons?): T;Defined in: retree-core/bin/ReactiveNode.d.ts:519
Memoize the result of fn, scoped to this ReactiveNode instance.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
key | string |
fn | () => T |
comparisons? | unknown[] |
Returns
T
Remarks
Two forms:
- Keyless (inside a getter):
this.memo(fn, deps?)— derives the cache key from the active getter's property name. Throws if called outside a getter or more than once in the same getter. - Explicit key:
this.memo(key, fn, deps?)— works anywhere; required when stacking multiple memo cells in one getter, or memoizing inside a method.
Cache semantics for comparisons:
- Omitted/
undefined: runfnunder automatic dependency trapping and recompute when one of the trapped reads changes. []: compute once and cache forever for this instance.[a, b, ...]: recompute when any cell shallow-changes usingObject.is. Tree-node cells are compared by their latest reproxy identity, so passingthis.listcorrectly invalidates whenlistmutates.
memo is a cache, not a subscription. It does not emit
nodeChanged or trigger React renders by itself. Pair it with
dependencies, Retree.select, or useSelect when you also need
notification behavior.
Example
class ListFilter extends ReactiveNode {
list: Card[] = [];
searchText = "";
// Keyless form
get filteredList() {
return this.memo(
() => this.list.filter((c) => c.text === this.searchText),
[this.list, this.searchText]
);
}
// Explicit-key form (e.g. when stacking two memos in one getter)
get pair() {
const a = this.memo("a", () => expensiveA(), [this.list]);
const b = this.memo("b", () => expensiveB(), [this.searchText]);
return { a, b };
}
get dependencies() { return [this.dependency(this.list)]; }
}Inherited from
moveTo()#
Call Signature#
moveTo<TValue>(destination, key?): this;Defined in: retree-core/bin/ReactiveNode.d.ts:170
Move this node to a new structural parent.
Type Parameters
| Type Parameter | Default type |
|---|---|
TValue extends object | ConvexNode |
Parameters
| Parameter | Type | Description |
|---|---|---|
destination | ConvexNode extends TValue ? TValue[] : never | Retree-managed destination collection or object. |
key? | number | Optional array insertion index, map key, or object property key. |
Returns
this
The latest reproxy for this node after it moves.
Remarks
This is a convenience wrapper around Retree.move. Use it from instance methods when a node should transfer ownership to another Retree-managed array, map, set, or object.
Do not call moveTo on a root node; roots have no parent to remove from.
Do not manually remove the node from its current parent before moving.
Example
class Task extends ReactiveNode {
public title = "";
get dependencies() {
return [];
}
public complete(done: Task[]) {
this.moveTo(done); // same as Retree.move(this, done)
}
}Inherited from
Call Signature#
moveTo<TKey, TValue>(destination, key): this;Defined in: retree-core/bin/ReactiveNode.d.ts:171
Move this node to a new structural parent.
Type Parameters
| Type Parameter | Default type |
|---|---|
TKey | unknown |
TValue extends object | ConvexNode |
Parameters
| Parameter | Type | Description |
|---|---|---|
destination | ConvexNode extends TValue ? Map<TKey, TValue> : never | Retree-managed destination collection or object. |
key | TKey | Optional array insertion index, map key, or object property key. |
Returns
this
The latest reproxy for this node after it moves.
Remarks
This is a convenience wrapper around Retree.move. Use it from instance methods when a node should transfer ownership to another Retree-managed array, map, set, or object.
Do not call moveTo on a root node; roots have no parent to remove from.
Do not manually remove the node from its current parent before moving.
Example
class Task extends ReactiveNode {
public title = "";
get dependencies() {
return [];
}
public complete(done: Task[]) {
this.moveTo(done); // same as Retree.move(this, done)
}
}Inherited from
Call Signature#
moveTo<TValue>(destination): this;Defined in: retree-core/bin/ReactiveNode.d.ts:172
Move this node to a new structural parent.
Type Parameters
| Type Parameter | Default type |
|---|---|
TValue extends object | ConvexNode |
Parameters
| Parameter | Type | Description |
|---|---|---|
destination | ConvexNode extends TValue ? Set<TValue> : never | Retree-managed destination collection or object. |
Returns
this
The latest reproxy for this node after it moves.
Remarks
This is a convenience wrapper around Retree.move. Use it from instance methods when a node should transfer ownership to another Retree-managed array, map, set, or object.
Do not call moveTo on a root node; roots have no parent to remove from.
Do not manually remove the node from its current parent before moving.
Example
class Task extends ReactiveNode {
public title = "";
get dependencies() {
return [];
}
public complete(done: Task[]) {
this.moveTo(done); // same as Retree.move(this, done)
}
}Inherited from
Call Signature#
moveTo<TDestination>(destination, key): this;Defined in: retree-core/bin/ReactiveNode.d.ts:173
Move this node to a new structural parent.
Type Parameters
| Type Parameter | Default type |
|---|---|
TDestination extends object | object |
Parameters
| Parameter | Type | Description |
|---|---|---|
destination | TDestination | Retree-managed destination collection or object. |
key | RetreeObjectMoveKey<TDestination, ConvexNode> | Optional array insertion index, map key, or object property key. |
Returns
this
The latest reproxy for this node after it moves.
Remarks
This is a convenience wrapper around Retree.move. Use it from instance methods when a node should transfer ownership to another Retree-managed array, map, set, or object.
Do not call moveTo on a root node; roots have no parent to remove from.
Do not manually remove the node from its current parent before moving.
Example
class Task extends ReactiveNode {
public title = "";
get dependencies() {
return [];
}
public complete(done: Task[]) {
this.moveTo(done); // same as Retree.move(this, done)
}
}Inherited from
mutation()#
protected mutation<Mutation>(mutation): RetreeConvexMutation<Mutation>;Defined in: retree-convex/src/BaseConvexNode.ts:96
Create a typed mutation function bound to this node's Convex client.
Type Parameters#
| Type Parameter |
|---|
Mutation extends MutationReference |
Parameters#
| Parameter | Type | Description |
|---|---|---|
mutation | Mutation | Convex mutation function reference. |
Returns#
RetreeConvexMutation<Mutation>
A typed mutation function with optional optimistic update support.
Remarks#
The returned function runs the Convex mutation. It does not update Retree
state by itself. Pass withOptimisticUpdate when the mutation should
immediately update a ConvexQueryNode; otherwise wait for the
subscribed query to emit a server value.
Example#
const toggle = this.mutation(api.tasks.toggleCompleted);
return toggle(
{ taskId },
{
withOptimisticUpdate: (ctx) => {
this.tasks.optimisticUpdate({
ctx,
apply(tasks) {
const task = tasks.find((item) => item._id === taskId);
if (task) task.isCompleted = !task.isCompleted;
},
});
},
}
);Inherited from#
onChanged()#
protected onChanged(_changes): void;Defined in: retree-core/bin/ReactiveNode.d.ts:410
Runs after this ReactiveNode receives a fresh reproxy.
Parameters#
| Parameter | Type |
|---|---|
_changes | INodeFieldChanges<unknown>[] |
Returns#
void
Remarks#
Override this when a node needs to synchronize derived state only after a
real Retree change. Retree runs this before nodeChanged /
treeChanged listeners flush. If no transaction is already active,
Retree starts one so state updates made here are batched with the reproxy
that triggered the effect.
Use this for small synchronization writes that should happen only after Retree has confirmed a real change. Avoid writing unconditionally here; guard against loops by checking whether the derived value actually changed.
Example#
class SearchState extends ReactiveNode {
public query = "";
public normalizedQuery = "";
get dependencies() {
return [];
}
protected onChanged() {
const next = this.query.trim().toLowerCase();
if (this.normalizedQuery !== next) {
this.normalizedQuery = next;
}
}
}Inherited from#
onObserved()#
protected onObserved(): void;Defined in: retree-core/bin/ReactiveNode.d.ts:358
Runs when this ReactiveNode gets its first active
nodeChanged or treeChanged observer.
Returns#
void
Remarks#
Override this for work that requires the proxied instance, such as starting external subscriptions that write back into Retree state.
Keep setup idempotent. Retree calls this when the first active
nodeChanged or treeChanged listener starts observing the node, not
when the node is constructed.
Example#
class LiveValue extends ReactiveNode {
public value = "";
@ignore private unsubscribe: (() => void) | null = null;
get dependencies() {
return [];
}
protected onObserved() {
this.unsubscribe = subscribe((value) => {
this.value = value; // ✅ emits through Retree
});
}
}Inherited from#
onUnobserved()#
protected onUnobserved(): void;Defined in: retree-convex/src/ConvexNode.ts:192
Runs when this ReactiveNode loses its last active
nodeChanged or treeChanged observer.
Returns#
void
Remarks#
Use this to clean up resources created in ReactiveNode.onObserved. Do not rely on it as a destructor for unobserved nodes; it only runs after observation had started.
Example#
protected onUnobserved() {
this.unsubscribe?.();
this.unsubscribe = null;
}Overrides#
paginatedQuery()#
protected paginatedQuery<Query>(query, ...options): ConvexPaginatedQueryNode<Query>;Defined in: retree-convex/src/ConvexNode.ts:140
Create a typed paginated query node bound to this node's Convex client.
Type Parameters#
| Type Parameter |
|---|
Query extends PaginatedQueryReference |
Parameters#
| Parameter | Type | Description |
|---|---|---|
query | Query | Convex paginated query function reference. |
...options | ConvexPaginatedQueryNodeOptionsArgs<Query> | Query arguments, initial page size, and optional initial state. |
Returns#
ConvexPaginatedQueryNode<Query>
A ConvexPaginatedQueryNode subscribed with this node's Convex client.
Remarks#
Use this for live paginated lists. The returned
ConvexPaginatedQueryNode emits through Retree when pages arrive
and exposes loadMore(...) for requesting additional items.
Example#
class MessagesState extends ConvexNode {
public readonly messages: ConvexPaginatedQueryNode<typeof api.messages.list>;
constructor(client: IConvexClient) {
super(client);
this.messages = this.paginatedQuery(api.messages.list, {
args: { channelId: "general" },
initialNumItems: 20,
});
}
get dependencies() {
return [];
}
}peekInto()#
peekInto<TResult>(fn): TResult;Defined in: retree-core/bin/ReactiveNode.d.ts:296
Run a read-only query against this node's raw object at native speed, then resolve the result back to its Retree-managed node when one exists.
Type Parameters#
| Type Parameter |
|---|
TResult |
Parameters#
| Parameter | Type | Description |
|---|---|---|
fn | (raw) => TResult | Read-only callback that receives the raw object behind this node. |
Returns#
TResult
The callback result, resolved to its managed node when one exists.
Remarks#
This is a convenience wrapper around Retree.peekInto for
this. The callback receives the raw object behind this node
(ReactiveNode.raw), so reads inside it skip proxy traps and are
not tracked as dependencies. If the returned value is an object that
belongs to a Retree tree, the latest managed node (reproxy or base
proxy) is returned instead; primitives and unmanaged objects are
returned as-is.
Only the returned value itself is resolved. Containers built inside the
callback (for example filter results) are returned unchanged, with
raw elements. Children that have never been read through the managed
tree have no proxy yet and resolve to their raw value; traverse the
path once, or use prepareTree / autoPrepare, when a managed result
is required.
Example#
class TaskList extends ReactiveNode {
public tasks: Task[] = [];
get dependencies() {
return [this.dependency(this.tasks)];
}
public findTask(id: string): Task | undefined {
// Scans raw at native speed; returns the managed task node.
return this.peekInto((raw) =>
raw.tasks.find((task) => task.id === id)
);
}
}Inherited from#
prepareTree()#
prepareTree(options?): void;Defined in: retree-core/bin/ReactiveNode.d.ts:472
Prepare lazy Retree child proxies below this ReactiveNode.
Parameters#
| Parameter | Type | Description |
|---|---|---|
options? | IRetreePrepareTreeOptions | Optional depth limit. Omit to prepare all reachable non-ignored child objects. |
Returns#
void
Remarks#
Retree lazily proxies plain object and array fields on ReactiveNodes. Call
this when an app wants to pay that first-touch cost during a controlled
phase, such as while showing a loading spinner. This walks only own data
properties, so computed getters like dependencies are not evaluated or
cached as child nodes. Fields marked with @ignore are skipped.
Do not call this for every render. Call it once during setup, loading, or before a known interaction that will traverse a large subtree.
Example#
class LargeNode extends ReactiveNode {
public sections = [{ title: "Intro", cards: [] }];
get dependencies() {
return [];
}
}
const node = Retree.root(new LargeNode());
node.prepareTree({ depth: 1 });Inherited from#
query()#
protected query<Query>(query, ...options): ConvexQueryNode<Query>;Defined in: retree-convex/src/ConvexNode.ts:100
Create a typed query node bound to this node's Convex client.
Type Parameters#
| Type Parameter |
|---|
Query extends QueryReference |
Parameters#
| Parameter | Type | Description |
|---|---|---|
query | Query | Convex query function reference. |
...options | ConvexQueryNodeOptionsArgs<Query> | Query arguments, optional initial state, and optional reconciler. |
Returns#
ConvexQueryNode<Query>
A ConvexQueryNode subscribed with this node's Convex client.
Remarks#
Use this for live Convex query data that should flow into Retree. The
returned ConvexQueryNode writes state, result, and error,
which can emit Retree events and re-render React subscribers.
Pass "skip" or later call updateArgs("skip") when the query should
be disabled. Prefer reconcilers for arrays so unchanged child items keep
stable identity.
Example#
class TasksState extends ConvexNode {
public readonly tasks: ConvexQueryNode<typeof api.tasks.byProject>;
constructor(client: IConvexClient) {
super(client);
this.tasks = this.query(api.tasks.byProject, {
args: { projectId: "p1" },
initialState: [],
});
}
get dependencies() {
return [];
}
}queryOnce()#
protected queryOnce<Query>(query, ...args): Promise<Awaited<FunctionReturnType<Query>>>;Defined in: retree-convex/src/BaseConvexNode.ts:143
Run a Convex query once without creating a subscription.
Type Parameters#
| Type Parameter |
|---|
Query extends QueryReference |
Parameters#
| Parameter | Type | Description |
|---|---|---|
query | Query | Convex query function reference. |
...args | OptionalConvexArgs<Query> | Query arguments. Optional for no-args queries. |
Returns#
Promise<Awaited<FunctionReturnType<Query>>>
Promise for the Convex query result.
Remarks#
Use this for imperative reads. It does not keep data live and does not emit Retree changes unless you assign the returned value into Retree state. Use ConvexNode.query when the value should stay subscribed.
Example#
const task = await this.queryOnce(api.tasks.getById, { taskId });
this.selectedTaskPreview = task; // ✅ emits if this field participates in RetreeInherited from#
raw()#
raw(): this;Defined in: retree-core/bin/ReactiveNode.d.ts:238
Get the raw, unproxied object behind this node for read-only, non-reactive access.
Returns#
this
The raw object behind this node.
Remarks#
This is a convenience wrapper around Retree.raw for this.
Reads on the returned object skip proxy traps entirely, so algorithms
that scan large collections owned by this node can run at native speed.
Treat the result as read-only: direct mutations skip Retree change
emission. Reads are invisible to reactivity, including this node's own
auto-trapped @memo / @select dependency collection. Throws when the
node is not yet Retree-managed (for example inside the constructor,
before Retree.root(...) or tree attachment).
Example#
class Leaderboard extends ReactiveNode {
public scores: number[] = [];
get dependencies() {
return [this.dependency(this.scores)];
}
get total() {
// Raw scan; reactivity comes from `dependencies`.
return this.raw().scores.reduce((sum, s) => sum + s, 0);
}
}Inherited from#
untracked()#
untracked<T>(fn): T;Defined in: retree-core/bin/ReactiveNode.d.ts:251
Run a synchronous function with Retree dependency tracking paused.
Type Parameters#
| Type Parameter |
|---|
T |
Parameters#
| Parameter | Type | Description |
|---|---|---|
fn | () => T | Function to run without dependency tracking. |
Returns#
T
The function's return value.
Remarks#
This is a convenience wrapper around Retree.untracked. Use it
inside auto-trapped @memo, @fnMemo, and @select bodies when bulk
reads should not become dependencies. Reads still go through Retree
proxies; writes still emit normally.