rungwiroon/BlazorGoogleMaps

Dispose question

ryanbuening opened this issue · 2 comments

Thanks for this great library! Given the code-behind class below, is it necessary to implement IDisposable and call Dispose() on GoogleMap?

public partial class UnassignedClaims : IDisposable
{ 
	private GoogleMap _map = new();
  ...
	public void Dispose()
	{
		_map.Dispose(); // necessary?
	}
}

GoogleMap looks like the following

namespace GoogleMapsComponents
{
	public class GoogleMap : MapComponent, IDisposable
	{
		...
		void IDisposable.Dispose()
		{
		}
	}
}

I dont know where you got such code for library. It is a bit different in reality.
https://github.com/rungwiroon/BlazorGoogleMaps/blob/master/GoogleMapsComponents/GoogleMap.razor#L82

Despite that component lifecycle in blazor automatically call dispose, so it is enough just create implementation if needed.
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/lifecycle?view=aspnetcore-5.0#component-disposal-with-idisposable-and-iasyncdisposable

Ahh, I am on 3.0.5.0. It looks like some changes were made with Dispose() in recent versions. Thanks for the reply.