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

Method tryUpdate_

src/core/context/values.js:496–517  ·  view source on GitHub ↗

* @param {IContextPropUsed } used * @private * @template T, DEP

(used)

Source from the content-addressed store, hash-verified

494 * @template T, DEP
495 */
496 tryUpdate_(used) {
497 // The value is not pending anymore. If any of the dependencies will remain
498 // unresolved, we will simply need to recomputed it.
499 const refreshParent = used.pending == Pending_Enum.PENDING_REFRESH_PARENT;
500
501 let newValue;
502 try {
503 newValue = this.calc_(used, refreshParent);
504 } catch (e) {
505 // This is the narrowest catch to avoid unrelated values breaking each
506 // other. The only exposure to the user-code are `recursive` and
507 // `compute` methods in the `IContextProp`.
508 rethrowAsync(e);
509 }
510
511 // Reset pending flag. It's good to reset it after the calculation to
512 // ensure that deps are automatically covered.
513 used.pending = Pending_Enum.NOT_PENDING;
514
515 // Check if the value has been updated.
516 this.maybeUpdated_(used, newValue);
517 }
518
519 /**
520 * @param {IContextPropUsed<T, ?>} used

Callers 1

checkUpdates_Method · 0.95

Calls 3

calc_Method · 0.95
maybeUpdated_Method · 0.95
rethrowAsyncFunction · 0.90

Tested by

no test coverage detected