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

Function observeComputation

packages/debugger/src/structure/walker.ts:233–255  ·  view source on GitHub ↗
(
    comp:            Solid.Computation,
    owner_to_update: Solid.Owner,
    config:          TreeWalkerConfig<TEl>,
)

Source from the content-addressed store, hash-verified

231const $WALKER = Symbol('tree-walker')
232
233function observeComputation<TEl extends object>(
234 comp: Solid.Computation,
235 owner_to_update: Solid.Owner,
236 config: TreeWalkerConfig<TEl>,
237): void {
238
239 // leaf nodes (ones that don't have children) don't have to cause a structure update
240 // Unless the walker is in DOM mode, then we need to observe all computations
241 // This is because DOM can change without the owner structure changing
242 let was_leaf = !comp.owned || comp.owned.length === 0
243
244 // copy values in case config gets mutated
245 let {rootId, onUpdate: onComputationUpdate, mode} = config
246
247 let handler = () => {
248 let is_leaf = !comp.owned || comp.owned.length === 0
249 let changed_structure = was_leaf !== is_leaf || !is_leaf || mode === TreeWalkerMode.DOM
250 was_leaf = is_leaf
251 onComputationUpdate(rootId, owner_to_update, changed_structure)
252 }
253
254 observeComputationUpdate(comp, handler, $WALKER)
255}
256
257function resolveElements<TEl extends object>(
258 value: unknown, eli: ElementInterface<TEl>, list: TEl[] = []

Callers 2

mapChildrenFunction · 0.85
mapOwnerFunction · 0.85

Calls 1

observeComputationUpdateFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…