Closed jbarrineau06 closed 3 years ago
The ToastService is registered as scoped so that it's compatible with Blazor Server. Say there were 3 people using a Blazor Server app. If one of them triggered a toast, all 3 of them would see it if the service was a singleton.
If you're writing a Blazor WebAssembly application then feel free to register it as a singleton as in Blazor WebAssembly singleton and scoped are the same. You just won't be able to use our helper method for registering the service.
I have a singleton network status service for my app, and I would like to be able to display a toast whenever the networks' status changes, but I can't seem to reference a scoped service in my singleton service.
On the surface it seems like the toast service should be a singleton as well, since we are just displaying a message, regardless of state. But I am pretty new to Blazor so you probably know something about it I don't.
If I simply register
ToastService
as a singleton, will that cause any issues?