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

Function producerUpdateValueVersion

packages/core/primitives/signals/src/graph.ts:314–339  ·  view source on GitHub ↗
(node: ReactiveNode)

Source from the content-addressed store, hash-verified

312 * Ensure this producer's `version` is up-to-date.
313 */
314export function producerUpdateValueVersion(node: ReactiveNode): void {
315 if (consumerIsLive(node) && !node.dirty) {
316 // A live consumer will be marked dirty by producers, so a clean state means that its version
317 // is guaranteed to be up-to-date.
318 return;
319 }
320
321 if (!node.dirty && node.lastCleanEpoch === epoch) {
322 // Even non-live consumers can skip polling if they previously found themselves to be clean at
323 // the current epoch, since their dependencies could not possibly have changed (such a change
324 // would've increased the epoch).
325 return;
326 }
327
328 if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
329 // None of our producers report a change since the last time they were read, so no
330 // recomputation of our value is necessary, and we can consider ourselves clean.
331 producerMarkClean(node);
332 return;
333 }
334
335 node.producerRecomputeValue(node);
336
337 // After recomputing the value, we're no longer dirty.
338 producerMarkClean(node);
339}
340
341/**
342 * Propagate a dirty notification to live consumers of this producer.

Callers 6

runDebugWatchFunction · 0.90
computedFunction · 0.90
linkedSignalGetterFunction · 0.90
linkedSignalSetFnFunction · 0.90
linkedSignalUpdateFnFunction · 0.90

Calls 5

consumerIsLiveFunction · 0.85
producerMarkCleanFunction · 0.85
producerMustRecomputeMethod · 0.65

Tested by

no test coverage detected