Update BlazorLibrary template to use newer interop APIs
This commit is contained in:
parent
a2bade57c3
commit
2f548f0b27
|
|
@ -9,7 +9,7 @@
|
||||||
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.2.0-preview1-34353</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
|
<MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>2.2.0-preview1-34353</MicrosoftAspNetCoreBenchmarkRunnerSourcesPackageVersion>
|
||||||
|
|
||||||
<!-- Used only in development when running the template contents directly from source -->
|
<!-- Used only in development when running the template contents directly from source -->
|
||||||
<TemplateBlazorPackageVersion>0.4.0-preview1-10300</TemplateBlazorPackageVersion>
|
<TemplateBlazorPackageVersion>0.5.0-preview1-10325</TemplateBlazorPackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
|
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
using System;
|
using Microsoft.JSInterop;
|
||||||
using Microsoft.AspNetCore.Blazor.Browser.Interop;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BlazorLibrary_CSharp
|
namespace BlazorLibrary_CSharp
|
||||||
{
|
{
|
||||||
public class ExampleJsInterop
|
public class ExampleJsInterop
|
||||||
{
|
{
|
||||||
public static string Prompt(string message)
|
public static Task<string> Prompt(string message)
|
||||||
{
|
{
|
||||||
return RegisteredFunction.Invoke<string>(
|
// Implemented in exampleJsInterop.js
|
||||||
"BlazorLibrary-CSharp.ExampleJsInterop.Prompt",
|
return JSRuntime.Current.InvokeAsync<string>(
|
||||||
|
"exampleJsFunctions.showPrompt",
|
||||||
message);
|
message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
// wrapped in a .NET API
|
||||||
|
|
||||||
Blazor.registerFunction('BlazorLibrary-CSharp.ExampleJsInterop.Prompt', function (message) {
|
window.exampleJsFunctions = {
|
||||||
|
showPrompt: function (message) {
|
||||||
return prompt(message, 'Type anything here');
|
return prompt(message, 'Type anything here');
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue