(id: string)
| 309 | * @param id The unique string ID of the signal node to watch or unwatch. |
| 310 | */ |
| 311 | export 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 | |
| 342 | function createDebugWatchNode(targetNode: ReactiveNode): DebugWatchNode { |
| 343 | const node: DebugWatchNode = { |
no test coverage detected