本文整理汇总了C#中ReactiveProperty.ToAsyncReactiveCommand方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveProperty.ToAsyncReactiveCommand方法的具体用法?C# ReactiveProperty.ToAsyncReactiveCommand怎么用?C# ReactiveProperty.ToAsyncReactiveCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveProperty
的用法示例。
在下文中一共展示了ReactiveProperty.ToAsyncReactiveCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShredReactivePropertyCase
public void ShredReactivePropertyCase()
{
var rp = new ReactiveProperty<bool>(false);
var taskSource1 = new TaskCompletionSource<object>();
var taskSource2 = new TaskCompletionSource<object>();
var canExecutedCounter1 = 0;
var canExecutedCounter2 = 0;
var command1 = rp.ToAsyncReactiveCommand();
command1.CanExecuteChanged += (_, __) => canExecutedCounter1++;
command1.Subscribe(_ => taskSource1.Task);
var command2 = rp.ToAsyncReactiveCommand();
command2.CanExecuteChanged += (_, __) => canExecutedCounter2++;
command2.Subscribe(_ => taskSource2.Task);
command1.CanExecute().IsFalse();
command2.CanExecute().IsFalse();
rp.Value = true;
command1.CanExecute().IsTrue();
command2.CanExecute().IsTrue();
canExecutedCounter1.Is(1);
canExecutedCounter2.Is(1);
command1.Execute();
command1.CanExecute().IsFalse();
canExecutedCounter1.Is(2);
command2.CanExecute().IsFalse();
canExecutedCounter1.Is(2);
taskSource1.SetResult(null);
command1.CanExecute().IsTrue();
canExecutedCounter1.Is(3);
command2.CanExecute().IsTrue();
canExecutedCounter1.Is(3);
command2.Execute();
command1.CanExecute().IsFalse();
canExecutedCounter1.Is(4);
command2.CanExecute().IsFalse();
canExecutedCounter1.Is(4);
taskSource2.SetResult(null);
command1.CanExecute().IsTrue();
canExecutedCounter1.Is(5);
command2.CanExecute().IsTrue();
canExecutedCounter1.Is(5);
}