MCPcopy
hub / github.com/angular/angular / producerUpdateValueVersion

Function producerUpdateValueVersion

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

Source from the content-addressed store, hash-verified

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

Callers 5

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

Calls 5

consumerIsLiveFunction · 0.85
producerMarkCleanFunction · 0.85
producerMustRecomputeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…