Skip to content

Commit

Permalink
ApplicationInsightsComponent.Dispose() - unsubscribe from NavigationM…
Browse files Browse the repository at this point in the history
…anager.LocationChanged event
  • Loading branch information
hakenr committed Feb 8, 2021
1 parent 85d9550 commit 9534a84
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.JSInterop;

namespace BlazorApplicationInsights
{
public partial class ApplicationInsightsComponent
public partial class ApplicationInsightsComponent : IDisposable
{
[Inject] private IApplicationInsights ApplicationInsights { get; set; }
[Inject] private NavigationManager NavigationManager { get; set; }
Expand All @@ -28,5 +29,10 @@ private async void NavigationManager_LocationChanged(object sender, LocationChan
{
await ApplicationInsights.TrackPageView();
}
}

public void Dispose()
{
NavigationManager.LocationChanged -= NavigationManager_LocationChanged;
}
}
}

0 comments on commit 9534a84

Please sign in to comment.