Class EventUtil
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
Utility class for opting out of rerendering in Blazor when an EventCallback is invoked. By default, components inherit from ComponentBase, which automatically invokes StateHasChanged after the component's event handlers are invoked. In some cases, it might be unnecessary or undesirable to trigger a rerender after an event handler is invoked. For example, an event handler might not modify the component state. https://learn.microsoft.com/aspnet/core/blazor/performance?view=aspnetcore-6.0#avoid-rerendering-after-handling-events-without-state-changes
public static class EventUtil
- Inheritance
-
EventUtil
- Inherited Members
Methods
AsNonRenderingEventHandler(ComponentBase, Action)
Converts the provided Action callback into a non-rendering event handler.
public static Action AsNonRenderingEventHandler(this ComponentBase component, Action callback)
Parameters
component
ComponentBaseThe component that handles exceptions.
callback
ActionThe action callback to be converted.
Returns
- Action
A non-rendering event handler.
AsNonRenderingEventHandler(ComponentBase, Func<Task>)
Converts the provided Func<TResult> callback into a non-rendering event handler.
public static Func<Task> AsNonRenderingEventHandler(this ComponentBase component, Func<Task> callback)
Parameters
component
ComponentBaseThe component that handles exceptions.
callback
Func<Task>The asynchronous callback to be converted.
Returns
AsNonRenderingEventHandler<TValue>(ComponentBase, Action<TValue>)
Converts the provided Action<T> callback into a non-rendering event handler.
public static Action<TValue> AsNonRenderingEventHandler<TValue>(this ComponentBase component, Action<TValue> callback)
Parameters
component
ComponentBaseThe component that handles exceptions.
callback
Action<TValue>The action callback to be converted.
Returns
- Action<TValue>
A non-rendering event handler.
Type Parameters
TValue
The type of the callback argument.
AsNonRenderingEventHandler<TValue>(ComponentBase, Func<TValue, Task>)
Converts the provided Func<T, TResult> callback into a non-rendering event handler.
public static Func<TValue, Task> AsNonRenderingEventHandler<TValue>(this ComponentBase component, Func<TValue, Task> callback)
Parameters
component
ComponentBaseThe component that handles exceptions.
callback
Func<TValue, Task>The asynchronous callback to be converted.
Returns
Type Parameters
TValue
The type of the callback argument.