sourcesOf
The sources the last run of a computation read, in reading order.
The sources the last run of a computation read, in reading order. Use it to inspect the graph (a debugger, a test); it is a snapshot, so changing the returned array changes no edge.
Import#
ts
import { sourcesOf } from "@shadow-js/core/extend";
Signature#
ts
function sourcesOf(node: Computation): Source[]
Parameters#
| Name | Description |
|---|---|
node |
The memo or effect. |
Returns#
The signals and memos it reads now.
Examples#
ts
import { createComputation, createSignalNode, flushSync, readSignal, sourcesOf } from "@shadow-js/core/extend";
const count = createSignalNode<number>(1, Object.is, "count");
const effect = createComputation({ kind: "effect", fn: () => void readSignal(count) });
flushSync();
console.log(sourcesOf(effect).length); // 1