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


C# ReactiveCommand.RegisterAsyncFunction方法代码示例

本文整理汇总了C#中ReactiveCommand.RegisterAsyncFunction方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveCommand.RegisterAsyncFunction方法的具体用法?C# ReactiveCommand.RegisterAsyncFunction怎么用?C# ReactiveCommand.RegisterAsyncFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReactiveCommand的用法示例。


在下文中一共展示了ReactiveCommand.RegisterAsyncFunction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoginWidgetViewModel

        public LoginWidgetViewModel(ILogPeopleIn loginManager)
        {
            Login = new ReactiveCommand(this.WhenAnyValue(x => x.Username, y => y.Password, (x, y) => !string.IsNullOrWhiteSpace(x) && !string.IsNullOrWhiteSpace(y)));
            Login.RegisterAsyncFunction(_ => loginManager.TryLogin(Username, Password))
                .Subscribe(x => Status = x ? "Success!" : "Failed.  Please try again.");

            Login.IsExecuting.Where(x => x).Select(_ => "Working...").BindTo(this, x => x.Status);

            _isEnabled = Login.IsExecuting.Select(x => !x).ToProperty(this, x => x.IsEnabled);
        }
开发者ID:pingortle,项目名称:CompsysTicketingPlayground,代码行数:10,代码来源:LoginWidgetViewModel.cs

示例2: ViewModel

        public ViewModel()
        {
            //GetItems();
            this.delays = new ObservableCollection<int>()
            {
                1, 2, 3, 4, 5
            };
            this.selectedDelay = this.delays[1];

            var executeSearchCommand = new ReactiveCommand();
            var results = executeSearchCommand.RegisterAsyncFunction(s => { return ExecuteSearch(s as string); });
            _executeSearchCommand = executeSearchCommand;

            this.ObservableForProperty<ViewModel, string>("SearchText")
                .Throttle(TimeSpan.FromMilliseconds(800))
                .Select(x => x.Value)
                .DistinctUntilChanged()
                .Where(x => !string.IsNullOrWhiteSpace(x))
                .Subscribe(_executeSearchCommand.Execute);

            _searchResults = new ObservableAsPropertyHelper<ObservableCollection<Item>>(results, _ => raisePropertyChanged("SearchResults"));
        }
开发者ID:rubans,项目名称:gitprojects,代码行数:22,代码来源:ViewModel.cs

示例3: RAFShouldActuallyRunOnTheTaskpool

        public void RAFShouldActuallyRunOnTheTaskpool()
        {
            var deferred = RxApp.MainThreadScheduler;
            var taskpool = RxApp.TaskpoolScheduler;

            try {
                var testDeferred = new CountingTestScheduler(Scheduler.Immediate);
                var testTaskpool = new CountingTestScheduler(Scheduler.NewThread);
                RxApp.MainThreadScheduler = testDeferred;
                RxApp.TaskpoolScheduler = testTaskpool;

                var fixture = new ReactiveCommand();
                var result = fixture.RegisterAsyncFunction(x => {
                    Thread.Sleep(1000);
                    return (int)x*5;
                });

                fixture.Execute(1);
                Assert.Equal(5, result.First());

                Assert.True(testDeferred.ScheduledItems.Count >= 1);
                Assert.True(testTaskpool.ScheduledItems.Count >= 1);
            } finally {
                RxApp.MainThreadScheduler = deferred;
                RxApp.TaskpoolScheduler = taskpool;
            }
        }
开发者ID:niefan,项目名称:ReactiveUI,代码行数:27,代码来源:ReactiveCommandTest.cs


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