Franklin Gil
Fuese bueno meterle un debouceTime al validador
Carlos Alejandro Hernández Mejía
Franklin Gil
Fuese bueno meterle un debouceTime al validador
Carlos Alejandro Hernández Mejía
En mi caso, usé debounceTime de la siguiente manera:
/** * Checks if the email is available * * @param userService Instance of UserService * @returns A function that returns an observable with the validation errors if any, otherwise null */ static checkIfEmailExists( userService: UserService, ): (control: AbstractControl) => Observable<ValidationErrors | null> { return (control: AbstractControl) => { return control.valueChanges.pipe( distinctUntilChanged(), debounceTime(500), switchMap((email) => userService.isAvailableByEmail(email)), map((response) => { if (!response.isAvailable) { return { emailExists: true }; } return null; }) ); }; }