MCPcopy Create free account
hub / github.com/angular/angular / toggleWatchSignal

Function toggleWatchSignal

packages/core/src/render3/util/signal_debug.ts:311–340  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

309 * @param id The unique string ID of the signal node to watch or unwatch.
310 */
311export function toggleWatchSignal(id: string): void {
312 const entry = signalDebugNodeMap.get(id);
313 if (!entry) {
314 console.warn(
315 `Could not find signal with ID "${id}". The ID may be wrong, or it could have been garbage collected.`,
316 );
317 return;
318 }
319
320 // If already watching this signal, dispose the watcher and stop watching.
321 if (entry.watch) {
322 const activeWatch = entry.watch.deref();
323 if (activeWatch && !activeWatch.destroyed) {
324 unwatchSignal(id);
325 return;
326 }
327 }
328
329 // Retrieve the target ReactiveNode from weak reference mapping.
330 const node = entry.node.deref();
331 if (!node) {
332 unwatchSignal(id);
333 signalDebugNodeMap.delete(id);
334 return;
335 }
336
337 const watchNode = createDebugWatchNode(node);
338 entry.watch = new WeakRef(watchNode);
339 runDebugWatch(watchNode);
340}
341
342function createDebugWatchNode(targetNode: ReactiveNode): DebugWatchNode {
343 const node: DebugWatchNode = {

Callers 1

Calls 7

unwatchSignalFunction · 0.85
createDebugWatchNodeFunction · 0.85
runDebugWatchFunction · 0.85
getMethod · 0.65
warnMethod · 0.65
derefMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected