diff --git a/build/dependencies.props b/build/dependencies.props index abf1981159..cfe4c20602 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -9,7 +9,7 @@ 2.2.0-preview1-34353 - 0.4.0-preview1-10300 + 0.5.0-preview1-10325 diff --git a/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/ExampleJsInterop.cs b/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/ExampleJsInterop.cs index a1095d8977..a673661c7b 100644 --- a/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/ExampleJsInterop.cs +++ b/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/ExampleJsInterop.cs @@ -1,14 +1,15 @@ -using System; -using Microsoft.AspNetCore.Blazor.Browser.Interop; +using Microsoft.JSInterop; +using System.Threading.Tasks; namespace BlazorLibrary_CSharp { public class ExampleJsInterop { - public static string Prompt(string message) + public static Task Prompt(string message) { - return RegisteredFunction.Invoke( - "BlazorLibrary-CSharp.ExampleJsInterop.Prompt", + // Implemented in exampleJsInterop.js + return JSRuntime.Current.InvokeAsync( + "exampleJsFunctions.showPrompt", message); } } diff --git a/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/content/exampleJsInterop.js b/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/content/exampleJsInterop.js index e765c02dbb..e35d0744fb 100644 --- a/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/content/exampleJsInterop.js +++ b/src/Microsoft.AspNetCore.Blazor.Templates/content/BlazorLibrary-CSharp/content/exampleJsInterop.js @@ -1,6 +1,8 @@ -// This file is to show how a library package may provide JavaScript interop features +// This file is to show how a library package may provide JavaScript interop features // wrapped in a .NET API -Blazor.registerFunction('BlazorLibrary-CSharp.ExampleJsInterop.Prompt', function (message) { +window.exampleJsFunctions = { + showPrompt: function (message) { return prompt(message, 'Type anything here'); -}); + } +};