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

Function observeValueUpdate

packages/debugger/src/main/observe.ts:98–116  ·  view source on GitHub ↗
(
    node: Solid.SourceMapValue | Solid.Computation,
    onUpdate: ValueUpdateListener,
    symbol: symbol,
)

Source from the content-addressed store, hash-verified

96 * Patches the owner/signal value, firing the callback on each update immediately as it happened.
97 */
98export function observeValueUpdate(
99 node: Solid.SourceMapValue | Solid.Computation,
100 onUpdate: ValueUpdateListener,
101 symbol: symbol,
102): void {
103 let map = SignalUpdateListeners.get(node)
104 if (!map) {
105 SignalUpdateListeners.set(node, (map = new Map()))
106 let value = node.value
107 Object.defineProperty(node, 'value', {
108 get: () => value,
109 set: newValue => {
110 for (const fn of map!.values()) fn(newValue, value)
111 value = newValue
112 },
113 })
114 }
115 map.set(symbol, onUpdate)
116}
117
118export function removeValueUpdateObserver(
119 node: Solid.SourceMapValue | Solid.Computation,

Callers 7

map_source_valueFunction · 0.90
collect_owner_detailsFunction · 0.90
update.test.tsFile · 0.90
observeNodeUpdateFunction · 0.90
observeSourcesFunction · 0.90
debugComputationFunction · 0.90
makeValueUpdateListenerFunction · 0.85

Calls 2

getMethod · 0.80
fnFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…