Skip to content

Commit 1610c07

Browse files
committed
Updates
1 parent 1322267 commit 1610c07

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

aspnetcore/blazor/javascript-interoperability/call-javascript-from-dotnet.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ IJSRuntime JS { get; set; }
462462

463463
Create an instance of a JS object using a constructor function and get the <xref:Microsoft.JSInterop.IJSObjectReference>/<xref:Microsoft.JSInterop.IJSInProcessObjectReference> .NET handle for referencing the instance with the following API:
464464

465-
* `InvokeNewAsync`
466-
* `InvokeNew`
465+
* `InvokeNewAsync` (asynchronous)
466+
* `InvokeNew` (synchronous)
467467

468468
Examples in this section demonstrate the API calls with the following `TestClass` with a constructor function (`constructor(text)`):
469469

@@ -512,8 +512,8 @@ An overload is available that takes a <xref:System.Threading.CancellationToken>
512512

513513
Read or modify the value of a JS object property, both data and accessor properties, with the following API:
514514

515-
* `GetValueAsync`/`SetValueAsync`
516-
* `GetValue`/`SetValue`
515+
* `GetValueAsync`/`SetValueAsync` (asynchronous)
516+
* `GetValue`/`SetValue` (synchronous)
517517

518518
Examples in this section demonstrate the API calls with the following JS object (`testObject`):
519519

aspnetcore/release-notes/aspnetcore-10/includes/blazor.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,10 @@ Blazor adds support for the following JS interop features:
292292
293293
The following asynchronous methods are available on <xref:Microsoft.JSInterop.IJSRuntime> and <xref:Microsoft.JSInterop.IJSObjectReference> with the same scoping behavior as the existing <xref:Microsoft.JSInterop.IJSRuntime.InvokeAsync%2A?displayProperty=nameWithType> method:
294294
295-
* `InvokeNewAsync(string identifier, object?[]? args)`: Invokes the specified JS constructor function asynchronously. The function is invoked with the `new` operator. In the following example, `jsInteropTests.TestClass` is a constructor function, and `classRef` is an <xref:Microsoft.JSInterop.IJSObjectReference>:
295+
* `InvokeNewAsync(string identifier, object?[]? args)`: Invokes the specified JS constructor function asynchronously. The function is invoked with the `new` operator. In the following example, `jsInterop.TestClass` is a class with a constructor function, and `classRef` is an <xref:Microsoft.JSInterop.IJSObjectReference>:
296296
297297
```csharp
298-
var classRef = await JSRuntime.InvokeNewAsync("jsInteropTests.TestClass",
299-
"text value");
298+
var classRef = await JSRuntime.InvokeNewAsync("jsInterop.TestClass", "Blazor!");
300299
var text = await classRef.GetValueAsync<string>("text");
301300
var textLength = await classRef.InvokeAsync<int>("getTextLength");
302301
```
@@ -305,13 +304,13 @@ The following asynchronous methods are available on <xref:Microsoft.JSInterop.IJ
305304
306305
```csharp
307306
var valueFromDataPropertyAsync = await JSRuntime.GetValueAsync<int>(
308-
"jsInteropTests.testObject.num");
307+
"jsInterop.testObject.num");
309308
```
310309
311310
* `SetValueAsync<TValue>(string identifier, TValue value)`: Updates the value of the specified JS property asynchronously. The property can't be a `get`-only property. If the property isn't defined on the target object, the property is created. In the following example, `num` is created on `testObject` with a value of 30 if it doesn't exist:
312311
313312
```csharp
314-
await JSRuntime.SetValueAsync("jsInteropTests.testObject.num", 30);
313+
await JSRuntime.SetValueAsync("jsInterop.testObject.num", 30);
315314
```
316315
317316
Overloads are available for each of the preceding methods that take a <xref:System.Threading.CancellationToken> argument or <xref:System.TimeSpan> timeout argument.
@@ -320,11 +319,11 @@ The special overload `IJSObjectReference.GetValueAsync<TValue>()` doesn't take a
320319
321320
The following synchronous methods are available on <xref:Microsoft.JSInterop.IJSInProcessRuntime> and <xref:Microsoft.JSInterop.IJSInProcessObjectReference> with the same scoping behavior as the existing <xref:Microsoft.JSInterop.IJSInProcessObjectReference.Invoke%2A?displayProperty=nameWithType> method:
322321
323-
* `InvokeNew(string identifier, object?[]? args)`: Invokes the specified JS constructor function synchronously. The function is invoked with the `new` operator. In the following example, `jsInteropTests.TestClass` is a constructor function, and `classRef` is an <xref:Microsoft.JSInterop.IJSInProcessObjectReference>:
322+
* `InvokeNew(string identifier, object?[]? args)`: Invokes the specified JS constructor function synchronously. The function is invoked with the `new` operator. In the following example, `jsInterop.TestClass` is a class with a constructor function, and `classRef` is an <xref:Microsoft.JSInterop.IJSInProcessObjectReference>:
324323
325324
```csharp
326325
var inProcRuntime = ((IJSInProcessRuntime)JSRuntime);
327-
var classRef = inProcRuntime.InvokeNew("jsInteropTests.TestClass", "text value");
326+
var classRef = inProcRuntime.InvokeNew("jsInterop.TestClass", "Blazor!");
328327
var text = await classRef.GetValueAsync<string>("text");
329328
var textLength = await classRef.InvokeAsync<int>("getTextLength");
330329
```
@@ -334,14 +333,14 @@ The following synchronous methods are available on <xref:Microsoft.JSInterop.IJS
334333
```csharp
335334
var inProcRuntime = ((IJSInProcessRuntime)JSRuntime);
336335
var valueFromDataProperty = inProcRuntime.GetValue<int>(
337-
"jsInteropTests.testObject.num");
336+
"jsInterop.testObject.num");
338337
```
339338
340339
* `SetValue<TValue>(string identifier, TValue value)`: Updates the value of the specified JS property synchronously. The property can't be a `get`-only property. If the property isn't defined on the target object, the property is created. In the following example, `num` is created on `testObject` with a value of 20 if it doesn't exist:
341340
342341
```csharp
343342
var inProcRuntime = ((IJSInProcessRuntime)JSRuntime);
344-
inProcRuntime.SetValue("jsInteropTests.testObject.num", 20);
343+
inProcRuntime.SetValue("jsInterop.testObject.num", 20);
345344
```
346345
347346
For more information, see the following sections of the *Call JavaScript functions from .NET methods* article:

0 commit comments

Comments
 (0)