本文整理汇总了C#中IReactiveCommand.ExecuteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IReactiveCommand.ExecuteAsync方法的具体用法?C# IReactiveCommand.ExecuteAsync怎么用?C# IReactiveCommand.ExecuteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReactiveCommand
的用法示例。
在下文中一共展示了IReactiveCommand.ExecuteAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertThrowsOnExecuteAsync
private static async Task AssertThrowsOnExecuteAsync(IReactiveCommand<Unit> command, Exception exception)
{
command.ThrownExceptions.Subscribe();
var failed = false;
try
{
await command.ExecuteAsync();
}
catch (Exception ex)
{
failed = ex == exception;
}
Assert.True(failed);
}
示例2: WebCallViewModel
/// <summary>
/// Setup the lookup logic, and use the interface to do the web call.
/// </summary>
/// <param name="caller"></param>
public WebCallViewModel(IWebCaller caller)
{
// Do a search when nothing new has been entered for 800 ms and it isn't
// an empty string... and don't search for the same thing twice.
var newSearchNeeded = this.WhenAny(p => p.InputText, x => x.Value)
.Throttle(TimeSpan.FromMilliseconds(800), RxApp.TaskpoolScheduler)
.DistinctUntilChanged()
.Where(x => !string.IsNullOrWhiteSpace(x));
_doWebCall = ReactiveCommand.CreateAsyncObservable(x => caller.GetResult(x as string));
newSearchNeeded.InvokeCommand(_doWebCall);
// Run the web call and save the results back to the UI when done.
var webResults =
_doWebCall.ExecuteAsync();
// The results are stuffed into the property, on the proper thread
// (ToProperty takes care of that) when done. We never want the property to
// be null, so we give it an initial value of "".
webResults
.ToProperty(this, x => x.ResultText, out _ResultTextOAPH, "");
}
示例3: assertExceptionForwardedToThrownExceptions
private static async Task assertExceptionForwardedToThrownExceptions(IReactiveCommand<Unit> command, Exception exception)
{
var exceptions = command.ThrownExceptions.CreateCollection();
await command.ExecuteAsync()
.Catch(Observable.Empty<Unit>())
.DefaultIfEmpty(Unit.Default);
Assert.Equal(1, exceptions.Count);
Assert.Contains(exception, exceptions);
}