Skip to content

Commit 6d40da4

Browse files
authored
[Blazor] synchronous-js-interop-call-js.md - fully synchronous code sample (#34332)
1 parent 1e42860 commit 6d40da4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

aspnetcore/blazor/includes/js-interop/synchronous-js-interop-call-js.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ When working with <xref:Microsoft.JSInterop.IJSObjectReference> in ASP.NET Core
2424

2525
```razor
2626
@inject IJSRuntime JS
27-
@implements IAsyncDisposable
27+
@implements IDisposable
2828
2929
...
3030
@@ -36,18 +36,20 @@ When working with <xref:Microsoft.JSInterop.IJSObjectReference> in ASP.NET Core
3636
{
3737
if (firstRender)
3838
{
39-
module = await JS.InvokeAsync<IJSInProcessObjectReference>("import",
40-
"./scripts.js");
39+
var jsInProcess = (IJSInProcessRuntime)JS;
40+
module = await jsInProcess.Invoke<IJSInProcessObjectReference>("import",
41+
"./scripts.js");
42+
var value = module.Invoke<string>("javascriptFunctionIdentifier");
4143
}
4244
}
4345
4446
...
4547
46-
async ValueTask IAsyncDisposable.DisposeAsync()
48+
void IDisposable.Dispose()
4749
{
4850
if (module is not null)
4951
{
50-
await module.DisposeAsync();
52+
await module.Dispose();
5153
}
5254
}
5355
}

0 commit comments

Comments
 (0)