Skip to content
Anders Malmgren edited this page Feb 20, 2021 · 1 revision

The setup for Blazor WASM is identical to .NET desktop

For the hub url you can do .WithHubUrl($"{builder.HostEnvironment.BaseAddress}EventAggregatorProxyHub")

Check out this blog for details

Keep in mind that Blazor WASM is a SPA solution. So if you switch view you need to unsubscribe to events since event aggregator connection is alive for the entire SPA session. It can be done like

public void Dispose()
{
    eventAggregator.Unsubscribe(this);
}

Make sure to register the model as a Scoped service otherwise dispose will not be called.

Clone this wiki locally