You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Choice between using the global events or a "local" (scoped) version of the event handler.
Description
Having the need for scoped events to send/receive messages in a single users session and not all users at the same time.
As we know, Blazor server Singleton registration is shared for all circuits.
Not all use cases involve that, so a scoped version should be available as well.
Maybe something like having two interfaces ISingletonEvents, IScopedEvents and a class PiralEvents
PiralEvents : IScopedEvents, ISingletonEvents
Then in the registration:
services.AddScoped<IScopedEvents, PiralEvents>();
services.AddSingleton<ISingletonEvents, PiralEvents>();
Then in the component do: @Inject IScopedEvents myEvents
or @Inject ISingletonEvents myEvents
Should be flexible enough.
Thoughts?
Background
N/A
Discussion
N/A
The text was updated successfully, but these errors were encountered:
Sounds good to me. I think having the scoped events handled via injection makes sense. This way, it would not conflict with the micro frontend API (and events).
IScopedEvents makes sense - ISessionEvents maybe, too. The current / singleton events I would keep on the service API (i.e,., IEvents - even though the interface is never implemented explicitly).
New Feature Proposal
Choice between using the global events or a "local" (scoped) version of the event handler.
Description
Having the need for scoped events to send/receive messages in a single users session and not all users at the same time.
As we know, Blazor server Singleton registration is shared for all circuits.
Not all use cases involve that, so a scoped version should be available as well.
Maybe something like having two interfaces ISingletonEvents, IScopedEvents and a class PiralEvents
PiralEvents : IScopedEvents, ISingletonEvents
Then in the registration:
services.AddScoped<IScopedEvents, PiralEvents>();
services.AddSingleton<ISingletonEvents, PiralEvents>();
Then in the component do:
@Inject IScopedEvents myEvents
or
@Inject ISingletonEvents myEvents
Should be flexible enough.
Thoughts?
Background
N/A
Discussion
N/A
The text was updated successfully, but these errors were encountered: