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

OnBeforeRender #1716

wants to merge 1 commit into
base: master


None yet
3 participants
Copy link

grahamehorner commented Nov 22, 2018

Added OnBeforeRender event to component ref: #1709


This comment has been minimized.

Copy link

SteveSandersonMS commented Dec 13, 2018

Thanks for proposing this. As much as possible, we're trying to minimise additions of lifecycle methods, because of seeing too many UI frameworks with complex lifecycles, leading developers to struggle to understand what they should plug in where, and the framework itself struggling to evolve while retaining backward compatibility.

The typical situation is that a framework adds, say, OnBeforeRender and people start using it. Control libraries appear and start doing stuff in that phase. Then people say, "Hey, we need AfterOnBeforeRender so we can do stuff after the control library does its thing", and then "We also need BeforeOnBeforeRender", etc. Then people struggle to know what event to use for what. For real-world examples, see ASP.NET WebForms or Unity.

So in the case of this PR, I think what I'd propose instead is that we change StateHasChanged to be virtual. That way, you can intercept any calls that come in (e.g., from the binding system) and put in your own logic to control whether rendering is requested (by calling base.StateHasChanged) or do other things both before and after rendering is requests. If anyone's interested in submitting a PR that makes StateHasChanged virtual and adds tests, please go ahead!

Hope this is OK.


This comment has been minimized.

Copy link

grahamehorner commented Dec 13, 2018

@SteveSandersonMS I totally agree a virtual StateHasChanged would be great; I'll open an issue and do a POC with reference back to this


This comment has been minimized.

Copy link

michaelvolz commented Dec 13, 2018

The less lifecycle methods the better, great idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment