docs(forms): Update catchError to return an `observable` (#34357)

Closes #34323

PR Close #34357
This commit is contained in:
Sonu Kapoor 2019-12-11 13:28:19 -05:00 committed by Kara Erickson
parent 6ce940315b
commit 5f2897be0b
1 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { catchError, map } from 'rxjs/operators'; import { catchError, map } from 'rxjs/operators';
import { HeroesService } from './heroes.service'; import { HeroesService } from './heroes.service';
import { Observable } from 'rxjs'; import { Observable, of } from 'rxjs';
// #docregion async-validator // #docregion async-validator
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
@ -19,7 +19,7 @@ export class UniqueAlterEgoValidator implements AsyncValidator {
): Promise<ValidationErrors | null> | Observable<ValidationErrors | null> { ): Promise<ValidationErrors | null> | Observable<ValidationErrors | null> {
return this.heroesService.isAlterEgoTaken(ctrl.value).pipe( return this.heroesService.isAlterEgoTaken(ctrl.value).pipe(
map(isTaken => (isTaken ? { uniqueAlterEgo: true } : null)), map(isTaken => (isTaken ? { uniqueAlterEgo: true } : null)),
catchError(() => null) catchError(() => of(null))
); );
} }
} }