MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / addNodeToGraph

Function addNodeToGraph

packages/debugger/src/dependency/collect.ts:47–72  ·  view source on GitHub ↗
(node: Solid.Signal | Solid.Memo | Solid.Computation)

Source from the content-addressed store, hash-verified

45}
46
47function addNodeToGraph(node: Solid.Signal | Solid.Memo | Solid.Computation) {
48 const isOwner = isSolidOwner(node)
49 const id = getSdtId(node, isOwner ? ObjectType.Owner : ObjectType.Signal)
50 if (Graph[id]) return
51
52 // observe each mapped node, to update the graph when it changes
53 const onNodeUpdate = OnNodeUpdate
54 observeNodeUpdate(node, () => onNodeUpdate(id))
55
56 Graph[id] = {
57 name: getNodeName(node),
58 type: getNodeType(node),
59 depth: lookupDepth(node),
60 sources:
61 'sources' in node && node.sources
62 ? node.sources.map(n =>
63 getSdtId(n, isSolidOwner(n) ? ObjectType.Owner : ObjectType.Signal),
64 )
65 : undefined,
66 observers:
67 'observers' in node && node.observers
68 ? node.observers.map(n => getSdtId(n, ObjectType.Owner))
69 : undefined,
70 graph: !isOwner && node.graph ? getSdtId(node.graph, ObjectType.Owner) : undefined,
71 } as SerializedDGraph.Node
72}
73
74function visitSources(node: Solid.Computation | Solid.Memo | Solid.Signal) {
75 let n = 0

Callers 3

visitSourcesFunction · 0.85
visitObserversFunction · 0.85
collectDependencyGraphFunction · 0.85

Calls 7

isSolidOwnerFunction · 0.90
getSdtIdFunction · 0.90
getNodeNameFunction · 0.90
getNodeTypeFunction · 0.90
observeNodeUpdateFunction · 0.85
onNodeUpdateFunction · 0.85
lookupDepthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…