Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Changing Blazor's behavior when checking for changed parameters

$
0
0

In this previous question: A group of parameter types that Blazor explicitly checks it is explained which types Blazor will detect diffs for, and which types it will assume are changed:

If StateHasChanged is called in a parent component, the Blazorframework rerenders child components if their parameters might havechanged:

  • For a group of parameter types that Blazor explicitly checks, Blazor rerenders a child component if it detects that any of the parametershave changed.
  • For unchecked parameter types, Blazor rerenders the child component regardless of whether or not the parameters have changed. Childcontent falls into this category of parameter types because childcontent is of type RenderFragment, which is a delegate that refers toother mutable objects.

However, I would like to be able to control the behavior so that I can explicitly check more types that I have control over. From what I can tell, the code that actually performs the check inside Blazor is all internal and so not amenable to changing. However, using a custom component it seems like we might be able to do a second pass through all the parameters in SetParametersAsync and return early if there are no changes according to our custom change detection logic.

Are there existing examples of code implementing this behavior? How to we make things have reasonable performance if we are using reflection to check all the parameter values?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>