Blazor.EventAggregator
Blazor.EventAggregator copied to clipboard
services.AddSingleton<IEventAggregator, EventAggregator.Blazor.EventAggregator>(); ???
Hi, Are you sure to register as singleton is a good way ? In this case all clients will receive notification on their pages.
Yeah this makes using services.AddEventAggregator();
make the whole library unusable for Blazor Server Side.
The workaround is to use this instead at ConfigureServices
services.AddScoped<EventAggregator.Blazor.IEventAggregator, EventAggregator.Blazor.EventAggregator>();
Hi @mikoskinen, I am sharing the same concerns as the two other developers. For Blazor Server Side, normally you would use it as a scoped service. Would it make sense to make the registration type configurable?
Thanks
@mikoskinen, @dradovic are you accepting PR's to fix this scope issue for Blazor Server?
Also, with the current library, how can I use:
services.AddScoped<EventAggregator.Blazor.IEventAggregator, EventAggregator.Blazor.EventAggregator>();
and set AutoRefresh = true
?
It is unexpected to be a singleton, instead of scoped. I also vote to change this. It's a super easy fix, no reason not to.