Replacing the linked field emits a normal nodeChanged event for the owning
ReactiveNode, but the assigned node keeps its existing parent. Reads
return the latest reproxy for the linked node.
Use this for selected items and cross-references. Do not use it when the target should become a structural child; use Retree.move / ReactiveNode.moveTo. Do not use it when two places need independent state; use Retree.clone.
import { ReactiveNode, Retree, link } from "@retreejs/core";
class EditorState extends ReactiveNode {
@link public selectedTask: Task | null = null;
get dependencies() {
return [];
}
}
const root = Retree.root({
tasks: [new Task()],
editor: new EditorState(),
});
root.editor.selectedTask = root.tasks[0]; // ✅ emits on editor
Retree.parent(root.editor.selectedTask) === root.tasks; // true
Field decorator that stores a reactive pointer to another Retree-managed node without making that node a structural child.