How does Blazor Work?
Last updated
Last updated
Although any major UI design pattern, such as MVC or MVP, can be implemented in Blazor, it is especially well-suited for the MVVM pattern:
DOM event: The user triggers an event (e.g., 'onclick').
Event relayed to View Model: Using a WebSocket connection, the event is sent to the server and then to the session View Model.
State change: The View Model executes business logic and updates the model.
View Model update: The View Model reacts to model changes, updating its state and triggering the HTML renderer.
HTML rendering: The HTML renderer uses the bound parameters from the Model to generate new HTML and compute the difference with the current state.
Visual delta transport: HTML differences are streamed asynchronously to the server, reducing data transfer and improving performance by updating only the necessary elements.
DOM update: The view is refreshed by directly modifying the DOM with the received data.