Add InvokeAsync with cancellation token overload to IJSRuntime (dotnet/extensions#1915)

Adds the InvokeAsync with cancellation token overload to IJSRuntime\n\nCommit migrated from 55f0b77464
This commit is contained in:
Javier Calvarro Nelson 2019-07-02 19:21:16 +02:00 committed by GitHub
parent 5e4f1f5fb2
commit 6069a89758
3 changed files with 18 additions and 1 deletions

View File

@ -32,6 +32,7 @@ namespace Microsoft.JSInterop
}
public partial interface IJSRuntime
{
System.Threading.Tasks.Task<TValue> InvokeAsync<TValue>(string identifier, System.Collections.Generic.IEnumerable<object> args, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
System.Threading.Tasks.Task<TValue> InvokeAsync<TValue>(string identifier, params object[] args);
}
public partial class JSException : System.Exception

View File

@ -1,7 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.JSInterop
@ -19,5 +20,15 @@ namespace Microsoft.JSInterop
/// <param name="args">JSON-serializable arguments.</param>
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
Task<TValue> InvokeAsync<TValue>(string identifier, params object[] args);
/// <summary>
/// Invokes the specified JavaScript function asynchronously.
/// </summary>
/// <typeparam name="TValue">The JSON-serializable return type.</typeparam>
/// <param name="identifier">An identifier for the function to invoke. For example, the value <code>"someScope.someFunction"</code> will invoke the function <code>window.someScope.someFunction</code>.</param>
/// <param name="args">JSON-serializable arguments.</param>
/// <param name="cancellationToken">A cancellation token to signal the cancellation of the operation.</param>
/// <returns>An instance of <typeparamref name="TValue"/> obtained by JSON-deserializing the return value.</returns>
Task<TValue> InvokeAsync<TValue>(string identifier, IEnumerable<object> args, CancellationToken cancellationToken = default);
}
}

View File

@ -2,7 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
@ -29,6 +31,9 @@ namespace Microsoft.JSInterop.Tests
{
public Task<T> InvokeAsync<T>(string identifier, params object[] args)
=> throw new NotImplementedException();
public Task<TValue> InvokeAsync<TValue>(string identifier, IEnumerable<object> args, CancellationToken cancellationToken = default) =>
throw new NotImplementedException();
}
}
}