-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Explicitly implement SetParametersAsync #12254
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
Conversation
This change converts SetParametersAsync to be an explicit interface implmenentation, and adds lifecyle methods for running code before or after the parameters are set. This is a design prototype, and not ready to be merged. I'll add tests if we like the general direction of this.
@@ -175,22 +190,22 @@ void IComponent.Configure(RenderHandle renderHandle) | |||
/// Method invoked to apply initial or updated parameters to the component. | |||
/// </summary> | |||
/// <param name="parameters">The parameters to apply.</param> | |||
public virtual Task SetParametersAsync(ParameterCollection parameters) | |||
Task IComponent.SetParametersAsync(ParameterCollection parameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our idea of making this explicit with overrides is that you can't use the base
keyword within in an explicit interface implementation. So it's not really possible to interact with by overriding or it would require a lot more design.
It seemed more natural to give you a before/after lifecycle model. The only use case I can really think of for before is to set default values, but it's otherwise SUPER painful to do.
{ | ||
parameters.SetParameterProperties(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was another issue I discovered here (or maybe it's intentional and I just missed it).
The way this is currently implemented, Init runs after parameters are set. This means that you can read parameter values in Init and it works. That seems really surprising and I wonder how often it's misused. I assumed that it's valuable to separate these things so that we can keep the exact timing of init being called an implementation detail.
Can we do some further design discussion on this? I'm concerned that the drawbacks of going this way might outweigh the benefits, and starting to wonder if the existing arrangement of At the very least, I think we would need to eliminate More broadly, it seems like the primary problem solved by There are also reasons why we'd want to expose the actual
Altogether I feel more comfortable with the general-purposeness of the
|
Yes, totally fine. There's a reason why I said this was a design prototype. |
Discussed and rejected! |
This change converts SetParametersAsync to be an explicit interface
implmenentation, and adds lifecyle methods for running code before or
after the parameters are set.
This is a design prototype, and not ready to be merged. I'll add tests
if we like the general direction of this.