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

Function _runAsyncValidator

packages/forms/src/model/abstract_model.ts:1466–1482  ·  view source on GitHub ↗
(shouldHaveEmitted: boolean, emitEvent?: boolean)

Source from the content-addressed store, hash-verified

1464 }
1465
1466 private _runAsyncValidator(shouldHaveEmitted: boolean, emitEvent?: boolean): void {
1467 if (this.asyncValidator) {
1468 this.status = PENDING;
1469 this._hasOwnPendingAsyncValidator = {
1470 emitEvent: emitEvent !== false,
1471 shouldHaveEmitted: shouldHaveEmitted !== false,
1472 };
1473 const obs = toObservable(this.asyncValidator(this));
1474 this._asyncValidationSubscription = obs.subscribe((errors: ValidationErrors | null) => {
1475 this._hasOwnPendingAsyncValidator = null;
1476 // This will trigger the recalculation of the validation status, which depends on
1477 // the state of the asynchronous validation (whether it is in progress or not). So, it is
1478 // necessary that we have updated the `_hasOwnPendingAsyncValidator` boolean flag first.
1479 this.setErrors(errors, {emitEvent, shouldHaveEmitted});
1480 });
1481 }
1482 }
1483
1484 private _cancelExistingSubscription(): boolean {
1485 if (this._asyncValidationSubscription) {

Callers

nothing calls this directly

Calls 3

toObservableFunction · 0.90
setErrorsMethod · 0.80
subscribeMethod · 0.65

Tested by

no test coverage detected