How do you handle events in Blazor?
In Blazor developers can handle any event by using the on<eventname> attribute with an HTML element. The attribute’s value is treated as an event handler. Blazor provides a set of event argument types that map to events. Following is a list of event types and the event argument type they map to: Focus events: FocusEventArgs Mouse events: MouseEventArgs Drag events: DragEventArgs Keyboard events: KeyboardEventArgs Input events: ChangeEventArgs/EventArgs Clipboard events: ClipboardEventArgs/EventArgs Touch events: TouchEventArgs Pointer events: PointerEventArgs Media events: EventArgs Progress events: ProgressEventArgs In the example, the event keypress is handled by using lambda expression the event is triggered for every keypress in the input element. Reference link: https://visualstudiomagazine.com/articles/2018/10/01/blazor-event-handling.aspx
How do you pass values from child to parent using EventCallBack in Blazor?
To pass values from a child to a parent component, see the following. Parent component Child component Reference link: https://docs.microsoft.com/en-us/aspnet/core/blazor/data-binding#child-to-parent-binding-with-chained-bind
How do you build Blazor apps with SignalR?
Blazor Server In server code, configure SignalR in the Startup.cs class file as follows. And then create a SignalR hub class as follows. Blazor client Create a Blazor app and add the package Blazor.Extensions.SignalR to the client. Then write the code to connect the Hub and event handler as follows. OnInitializedAsync method, connect to the Web API. ReceiveMessage method, used in the SignalRHub class. ReceiveMessage method, concatenate the name and message parameters, and append them to a list. The StateHasChanged method will update the bindings in the HTML. The SendMessage method will invoke the Send method in the hub with name and message parameters. Reference link: https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr-blazor-webassembly?view=aspnetcore-3.1&tabs=visual-studio#add-the-signalr-client-library
What about performance when using cascading values in Blazor?
When a cascading value is changed, the new value will be sent down the component tree and all components that use it will be updated. Therefore, Blazor has to keep a watch on the value continuously. This takes up resources and, in a large application, could end up causing performance issues. If the cascading value will never change, we can stop keeping watch continuously. There is a IsFixed parameter in the CascadingValue component. It is set to false by default but if set it to true, Blazor will not monitor it for changes. Reference link: https://chrissainty.com/understanding-cascading-values-and-cascading-parameters/
How do you update the cascading values in Blazor?
The cascading values can be updated using an event, as in the following example. Parent component CascadingChild.razor CascadingChild1.razor Reference link https://chrissainty.com/understanding-cascading-values-and-cascading-parameters/