Form Status Changes observable, should also emit the Value used for validation.
See original GitHub issueWhich @angular/* package(s) are relevant/releated to the feature request?
forms
Description
We have a requirement to make a call to API every time the value of form is changed, we need to make an API call, if it is valid. Form is a complex form with multiple child groups and child arrays.
Since valueChanges is fired before statusChanges and since statusChanges can be async; it is not possible to do this in a reliable way.
Proposed solution
statusChanges event should also emit the value used for calculating the status.
Alternatives considered
To solve this issue, I am using the following observable. This is not ideal, however I could not think of a better way.
const filterSetValidityChanged$ = this.searchForm.get('filterSet').statusChanges.pipe();
const filterSetChanged$ = this.searchForm.get('filterSet').valueChanges.pipe();
const filterSetChangedAndIsValid$ = filterSetValidityChanged$.pipe(
filter(a => a === 'VALID'),
withLatestFrom(filterSetChanged$),
map(([, value]) => value));
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:11 (8 by maintainers)
Top Results From Across the Web
StatusChanges in Angular Forms - TekTutorialsHub
StatusChanges event raised by the Angular forms whenever the it calculates validation status of Form. Returns an observable so that you can ......
Read more >valueChanges and statusChanges in Angular
valuesChanges() Property is an observable that emits an event every time the value of a FormGroup or FormControl changes. valueChanges() ...
Read more >Angular valueChanges and statusChanges - ConcretePage.com
This page will walk through Angular valueChanges and statusChanges properties of FormControl , FormArray and FormGroup classes.
Read more >Angular reactive forms: how show validation errors in a dialog?
valueChanges: Observable --> emits an event every time the value of the control changes ... Here statusChanges Observable can also be used.
Read more >Value & Status Change events | Reactive Forms | Angular 13+
In this lecture you are going to learn about value and status change events in Angular Form. These are the events which gets...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the issue is that the value might have changed in the meantime, since the validation is async and could take a while.
This might be solvable in the context of #10887, if we had a unified event payload that contained both the
value
andstatus
for all state changes.