Skip to content

Commit

Permalink
Merge pull request #52 from hakenr/disposable
Browse files Browse the repository at this point in the history
ApplicationInsightsComponent.Dispose()
  • Loading branch information
IvanJosipovic authored Feb 11, 2021
2 parents 2943dbb + 9534a84 commit 695d7eb
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 695d7eb

Please sign in to comment.