Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WI00745224 - JavaScript interop calls cannot be issued at this time #48

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Blazor.Diagrams/Components/DiagramCanvas.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Threading.Tasks;
using Blazor.Diagrams.Core.Behaviors;
using Blazor.Diagrams.Core.Behaviors;
using Blazor.Diagrams.Core.Geometry;
using Blazor.Diagrams.Extensions;
using Microsoft.AspNetCore.Components;
Expand Down Expand Up @@ -40,6 +38,9 @@ public async ValueTask DisposeAsync()
await JSRuntime.UnobserveResizes(elementReference);

_reference.Dispose();
_reference = null!;

GC.SuppressFinalize(this); // CA1816
}

private string GetLayerStyle(int order)
Expand Down
13 changes: 9 additions & 4 deletions src/Blazor.Diagrams/Extensions/JSRuntimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Threading.Tasks;
using Blazor.Diagrams.Core.Geometry;
using Blazor.Diagrams.Core.Geometry;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;

Expand Down Expand Up @@ -28,7 +26,14 @@ public static async Task ObserveResizes<T>(this IJSRuntime jsRuntime, ElementRef

public static async Task UnobserveResizes(this IJSRuntime jsRuntime, ElementReference element)
{
await jsRuntime.InvokeVoidAsync("ZBlazorDiagrams.unobserve", element, element.Id);
try
{
await jsRuntime.InvokeVoidAsync("ZBlazorDiagrams.unobserve", element, element.Id);
}
catch (JSDisconnectedException)
{
// Ignore, JSRuntime was already disconnected
}
}

public static async Task AddDefaultPreventingForWheelHandler(this IJSRuntime jsRuntime, ElementReference element)
Expand Down
Loading