-
Book Overview & Buying
-
Table Of Contents
Blazor WebAssembly by Example - Third Edition
By :
In a Blazor WebAssembly app, the browser's memory is used to hold the application's state. This means that during navigation, the state is lost unless preserved. The AppState pattern preserves the application's state.
In the AppState pattern, a service is added to a DI container to coordinate the state between related components. The service contains all the state that needs to be maintained. Because the service is managed by the DI container, it outlives individual components and retains the state of the application as the UI changes.
The service can store simple properties or complex objects. One service can be used to manage the state of multiple components across the entire application. It coordinates updates via events like OnChange, ensuring the UI rerenders seamlessly. Benefits include clean separation of UI (presentation) from business logic, plus scalability to app-wide state management.
Application state in browser memory is lost on page reload...