MCPcopy Index your code
hub / github.com/ampproject/amphtml / maybeUpdated_

Method maybeUpdated_

src/core/context/values.js:525–545  ·  view source on GitHub ↗

* @param {IContextPropUsed } used * @param {T} value * @private * @template T

(used, value)

Source from the content-addressed store, hash-verified

523 * @template T
524 */
525 maybeUpdated_(used, value) {
526 const {prop, value: oldValue} = used;
527 const {key} = prop;
528 const usedByKey = this.usedByKey_;
529 if (
530 oldValue === value ||
531 used !== usedByKey?.get(key) ||
532 !this.isConnected_()
533 ) {
534 // Either the value didn't change, or no one needs this value anymore.
535 return;
536 }
537
538 used.value = value;
539
540 // Notify subscribers.
541 const {subscribers} = used;
542 for (const handler of subscribers) {
543 handler(value);
544 }
545 }
546
547 /**
548 * The used value calculation algorithm.

Callers 1

tryUpdate_Method · 0.95

Calls 3

isConnected_Method · 0.95
handlerFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected