A lightweight event aggregator for Blazor that enables indirect component-to-component communication through publish/subscribe messaging.
Blazor.EventAggregator is a lightweight event aggregator library specifically designed for Blazor applications. It implements the publish/subscribe pattern to enable indirect communication between Blazor components, allowing components to broadcast events and other components to react to those events without direct dependencies.
Blazor developers building applications with multiple components that need to communicate without tight coupling, particularly those using server-side Blazor or WebAssembly who need a clean messaging solution.
Developers choose Blazor.EventAggregator because it provides a proven event aggregator pattern adapted specifically for Blazor, offers simple dependency injection integration, and includes optional automatic state refresh functionality to simplify UI updates.
Lightweight Event Aggregator for Blazor (Razor Components).
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Based on the established Caliburn.Micro event aggregator code, ensuring minimal overhead and reliability from a battle-tested implementation, as noted in the README.
Easy setup with a single line in ConfigureServices (services.AddEventAggregator()) and straightforward injection via IEventAggregator interface, as shown in the publisher and subscriber examples.
Optional auto-refresh functionality calls StateHasChanged on subscriber components after event handling, reducing the need for manual UI updates, though it relies on reflection.
Specifically designed to work with Blazor components using inheritance and code-behind patterns, as demonstrated in the full examples for publishers and subscribers.
The library has only been tested with server-side Blazor, and while no issues are known for WebAssembly, this lack of thorough testing could lead to unforeseen compatibility problems, as admitted in the README.
Auto-refresh relies on reflection and assumes subscribers inherit from ComponentBase, which limits flexibility for components using alternative patterns and adds performance overhead.
Lacks advanced event handling features such as event filtering, scoping, or built-in error handling, making it less suitable for complex event-driven architectures beyond simple publish/subscribe.