-
Notifications
You must be signed in to change notification settings - Fork 5
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
[ng-core] [WrappedFormControlSuperclass] emitOutgoingValue should not be called implicitly #37
Comments
@DmitryEfimenko If you happen to be available right now, I'm looking at this on my twitch stream. If you get this message very soon, please drop in and say hi so we can discuss! https://www.twitch.tv/ersimont |
Too slow. It was right at the end of my stream. :) If you don't mind, would you check out the video? Then you can respond to my thoughts here, or on Discord. You'll want to skip to around the 1:49:00 mark: https://www.twitch.tv/videos/978077129 |
I did. It was great to watch your though process. It's a shame I missed the twitch invite :) To answer your question "What is the control value when the user typed in an invalid value - something that does not match available options"?
As you mentioned, the first and second scenarios are perfectly supported by the I can also see your point when you were speculating whether the WrappedFormControlSuperclass is suitable at all for my use-case. But then you were saying that I might find useful the other 95% of the class - which is exactly the case! It would indeed be a shame if I could not use it. I wonder if the functionality in question could be made optional and enabled by default. This way everybody would be happy and it would not be a breaking change. If we were to add such customization, I think it would have to be in a form of a new method that would enable/disable this functionality. Also, adding Finally, I did join the Discord. Perhaps we could chat some time tomorrow. |
What about overriding |
definitely sounds like a possibility. But now we're getting into this situation of emitting duplicate values. I think the following change would make my use-case work: const valuesToEmit$ = this.formControl.valueChanges.pipe(
map(value => this.innerToOuter(value)),
distinctUntilChanged()
);
this.subscribeTo(valuesToEmit$, (value) => {
this.emitOutgoingValue(value);
}); |
I understand that the utility class attempts to reduce the boilerplate as much as possible and in doing so, it assumes that the sub class will want to call emitOutgoingValue any time when
this.formControl.valueChanges
emits a new value. However, this just may not be true for certain components.Imagine creating a autocomplete component, which only allows values from the provided options. It should only emit a new value if the value typed into the control matches one of the options.
I think lines 56-58 need to be removed.
Unfortunately, that would be a breaking change.
The text was updated successfully, but these errors were encountered: