Application state
In a Blazor WebAssembly app, the browser's memory is used to hold the application's state. This means that when the user navigates between pages, the state is lost, unless we preserve it. We will be using the AppState pattern to preserve 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 of the states that need to be maintained. Because the service is managed by the DI container, it can outlive individual components and retain the state of the application as the UI is changing.
The service can be a simple class or a complex class. One service can be used to manage the state of multiple components across the entire application. A benefit of the AppState pattern is that it leads to a greater separation between presentation and business logic.
Important note
The application state that is held in the browser's memory is lost...