feat(pokemon): debounce async validator and reset validating state in finalize#180
Merged
Ismaestro merged 1 commit intoIsmaestro:masterIsmaestro/angular-example-app:masterfrom Aug 12, 2025
OrlPep:feat/pokemon-validation-debounceOrlPep/angular-example-app:feat/pokemon-validation-debounceCopy head branch name to clipboard
Merged
feat(pokemon): debounce async validator and reset validating state in finalize#180Ismaestro merged 1 commit intoIsmaestro:masterIsmaestro/angular-example-app:masterfrom OrlPep:feat/pokemon-validation-debounceOrlPep/angular-example-app:feat/pokemon-validation-debounceCopy head branch name to clipboard
Ismaestro merged 1 commit intoIsmaestro:masterIsmaestro/angular-example-app:masterfrom
OrlPep:feat/pokemon-validation-debounceOrlPep/angular-example-app:feat/pokemon-validation-debounceCopy head branch name to clipboard
Conversation
✅ Deploy Preview for angular-example-app ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
OrlPep
commented
Aug 9, 2025
| } | ||
|
|
||
| this.pokemonName.set(pokemonName.toLowerCase()); | ||
| this.pokemonName.set(pokemonName); |
Author
There was a problem hiding this comment.
Removed the extra .toLowerCase() call here because the value was already being normalized earlier in validate().
Ismaestro
approved these changes
Aug 12, 2025
| } | ||
|
|
||
| this.pokemonName.set(pokemonName.toLowerCase()); | ||
| this.pokemonName.set(pokemonName); |
Owner
|
Nice job! thanks!! |
Author
Sure thing, happy to collaborate! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The register form’s async Pokémon validator currently issues a network request on each keystroke and toggles the validating spinner accordingly.
Motivation / Problem Statement
Rapid typing triggers multiple unnecessary API calls, keeps the validating spinner active and causes visible flicker as validation rapidly starts/stops. Debouncing prevents redundant requests and avoids unnecessary validation cycles and spinner flicker during continuous typing.
Solution Overview
timer+switchMapso the request is sent only after typing pauses.isPokemonValidatingreset intofinalizeso it runs after both success and error paths (single, consistent state flip).pokemonId = -1when the input is empty to reflect the absence of a selected Pokémon and avoid superfluous requests.pokemonNameupdates unchanged aside from the debounce flow.catchError(() => of({ pokemonName: true })), ensuring the validator always returns a value (eithernullor an error object) even when the request fails.Scope of Change
File changed:
src/app/core/validators/pokemon.validator.tsonly.No changes to component templates, routes, or backend APIs.
User-Visible Behavior
isPokemonValidating) is set once per validation attempt and reset after completion, no rapid on/off toggles during typing.pokemonId = -1).Testing Instructions
Run: npm i && npm start
pika…), then pause:isPokemonValidatingisfalse.pokemonIdbecomes-1.Performance / UI State Notes
Related Links / Issues
N/A
Before / After GIFs
Before
After
Checklist
npm run lint)npm run build)