也许我遗漏了一些东西,但是我无法让ReactiveCommand阻止基于可观察到的canExecute的执行。
下面是我能想到的最简单的例子。我希望这个命令永远不会开火,不管它是什么。
我遗漏了什么?
void Main()
{
var canExecute = Observable.Return(false);
var myCommand = ReactiveCommand.CreateAsyncTask(canExecute, m => functions.doAllThings(m));
myCommand.Subscribe(x=>"executing".Dump());
myCommand.Execute("Tom"); // This fires the command. I would have expected it to block
}
static class functions
{
public static Task doAllThings(object message)
{
var result = Task.Run(() =>{
"running task...".Dump();
return "hello " + (string)message;});
return result;
}
}注意--这是Executing a command from another command的一个“叉子”。我认为这是更多的核心问题。
发布于 2014-09-03 05:00:13
这是精心设计的。ReactiveUI不会阻止您显式地调用Execute / ExecuteAsync,并且相信您知道自己在做什么,™
https://stackoverflow.com/questions/25636199
复制相似问题