(targetNode: ReactiveNode)
| 340 | } |
| 341 | |
| 342 | function createDebugWatchNode(targetNode: ReactiveNode): DebugWatchNode { |
| 343 | const node: DebugWatchNode = { |
| 344 | ...REACTIVE_NODE, |
| 345 | consumerIsAlwaysLive: true, |
| 346 | consumerAllowSignalWrites: true, |
| 347 | dirty: true, |
| 348 | kind: 'effect', |
| 349 | targetNode: new WeakRef(targetNode), |
| 350 | destroyed: false, |
| 351 | consumerMarkedDirty: () => { |
| 352 | if (node.destroyed) return; |
| 353 | // Schedule watch re-execution asynchronously in the next microtask after |
| 354 | // the signal update cycle completes, ceding the main thread back to the |
| 355 | // framework and avoiding synchronous re-entrancy during value computation. |
| 356 | queueMicrotask(() => runDebugWatch(node)); |
| 357 | }, |
| 358 | }; |
| 359 | return node; |
| 360 | } |
| 361 | |
| 362 | function runDebugWatch(node: DebugWatchNode): void { |
| 363 | if (node.destroyed) return; |
no test coverage detected