Skip to content

Commit

Permalink
docs(forms): Update catchError to return an observable (angular#34357)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonukapoor authored and kara committed Dec 11, 2019
1 parent 6ce9403 commit 5f2897b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@angular/forms';
import { catchError, map } from 'rxjs/operators';
import { HeroesService } from './heroes.service';
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';

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

0 comments on commit 5f2897b

Please sign in to comment.