当前位置: 首页>>代码示例>>C#>>正文


C# IReactiveCommand.ExecuteAsync方法代码示例

本文整理汇总了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);
        }
开发者ID:OlexaLe,项目名称:RxLite,代码行数:17,代码来源:ReactiveCommandTests.cs

示例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, "");
        }
开发者ID:CRuppert,项目名称:ReactiveUI.Samples,代码行数:28,代码来源:WebCallViewModel.cs

示例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);
        }
开发者ID:bestwpw,项目名称:ReactiveUI,代码行数:11,代码来源:ReactiveCommandTest.cs


注:本文中的IReactiveCommand.ExecuteAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。