I am wondering if there is something similar to this in Blazor:
@injectScoped IMyService Service
So the injected instance will be created when the component is created and destroyed when the component is destroyed.
Any child component using the same @injectScoped directive will receive the parent’s instance, not the singleton (global) one created at the root.
I am still searching for how to achieve that in a Blazor Webassembly app.
>Solution :
OwningComponentBase or OwningComponentBase<>
@inherits OwningComponentBase<SomeService>
<h3>SomeComponent</h3>
@code {
SomeService myService => base.Service;
}