State & DI
Share logic and data through dependency injection.
Registering services
builder.Services.AddScoped<CartService>();Injecting them
Use @inject in markup or [Inject] in code to get a service instance.
@inject CartService Cart
<p>@Cart.Count items</p>