Hook to be warned when the form has changed?
See original GitHub issueI think that a very common thing with form is subscribing to the form value and also start that observable with the current form value.
Example of doing that with this lib:
this.formGroup.valueChanges
.pipe(
startWith(this.formGroupValues),
tap(() => this.doSomething())
);
Annoying part is that in doing so, we have to manage the subscription and the cleanup when the component’s being destroyed.
I wonder if it would be worth having a method taking care of the whole observable/async part so that to react to a form change we would only need to do something like that:
@MyComponent({...})
class MyComponent extends NgxSubForm<FormInterface> {
protected getFormControls(): Controls<FormInterface> {
return {...};
}
protected onFormUpdate({ formValue, isInitialValue }: FormChange<FormInterface>) {
// do something with formValue, also possible to make a condition if you don't want
// to react to the initial value
}
}
@zakhenry what do you think?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
React hook Form know when value is modified - Stack Overflow
Anyone have idea. I want know if any of the value is changed and update the state edited to true. After i provide...
Read more >UserEvent.type causes act warning with react-hook-form with ...
When using fireEvent.change, the warning does not show up. I can wrap the userEvent.type in an act(), but I feel like that hides...
Read more >useForm | React Hook Form - Simple React forms validation
useForm is a custom hook for managing forms with ease. ... By default, re-validation is actioned during the input change event.
Read more >Rules of Hooks - React
Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. Hooks are...
Read more >Integrated Public Alert & Warning System | FEMA.gov
The Integrated Public Alert & Warning System (IPAWS) is FEMA's national system for local alerting that provides authenticated emergency and ...
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
Oh oops I only saw the first example, yea I guess is initial is sufficient
On Wed, 15 May 2019 at 8:57 am, Maxime notifications@github.com wrote:
– Zak Henry
🎉 This issue has been resolved in version 2.5.0 🎉
The release is available on:
Your semantic-release bot 📦🚀