-
Book Overview & Buying
-
Table Of Contents
Blazor WebAssembly by Example - Third Edition
By :
You've learned to use DI to apply the AppState pattern to preserve state in a Blazor WebAssembly app.
In this chapter, I introduced application state and dependency injection (DI). I explained how to use a DI container and how to inject a service into a component. I also explained the differences between the singleton, scoped, and transient service lifetimes.
You used the Blazor WebAssembly Standalone App project template to create a new project. You installed Bootstrap to style the frontend. You added a Store component to the project and demonstrated that the application state is lost when you navigate between pages. To maintain the application's state, you registered the CartService service in the DI container and verified that by using the AppState pattern, you can maintain the shopping cart's state. Finally, you added the cart's running total to all the pages.
You can use DI to maintain the application state for any Blazor WebAssembly app.
In the next chapter...