Visitar URL original
Forms: Unified Control State Change Events · Issue #42862 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20210811120832/https://github.com/angular/angular/issues/42862
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms: Unified Control State Change Events #42862

Open
dylhunn opened this issue Jul 14, 2021 · 1 comment
Open

Forms: Unified Control State Change Events #42862

dylhunn opened this issue Jul 14, 2021 · 1 comment

Comments

@dylhunn
Copy link
Contributor

@dylhunn dylhunn commented Jul 14, 2021 •

Which @angular/* package(s) are relevant/releated to the feature request?

forms

Description

The ability for AbstractControl-based classes (such as FormControl) to produce more events is a highly requested feature (lots of feedback in #10887, also #41088 and others; #24444 is also a use case). Adding more observables similar to the current valueChanges and statusChanges is the most straightforward way to extend AbstractControl, however, as the number of such observables increases (for example pristine, dirty, etc) it might become less ergonomic and more expensive to maintain.

Proposed solution

We could introduce a new observable (and still support valueChanges and statusChanges for backwards compatibility) containing all events produced in various situations, so it's possible to subscribe, stream, and filter as needed. Each event in this stream might contain additional meta information such as a reference to an instance that produced the event, event type, etc. We would need a unified payload design that works with all the event types, and satisfies the use cases in the above linked issues.

However before making a final decision, we'd need to perform more research and design work, to make sure that this approach is viable.

Also note that adding this stream could simplify ControlValueAccessor, as per #24444 and #27315.

Alternatives considered

Adding individual observables on a case-by-case basis is likely infeasible, both from an API consistency perspective and an API bloat perspective.

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Jul 15, 2021

FYI #31963 has some proposals on how event payload may look like.

@AndrewKushnir AndrewKushnir changed the title Generic observable for changes on AbstractControl Forms: generic observable for changes on AbstractControl Jul 15, 2021
@alxhub alxhub moved this from Needs Discussion to Backlog in Feature Requests Jul 15, 2021
@dylhunn dylhunn changed the title Forms: generic observable for changes on AbstractControl Forms: Unified Control State Change Events Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants