Perhaps I'm missing something, however I can't get ReactiveCommand to prevent execution based on the canExecute observable.
Below is the simplest example I can conjure. I would expect the command to never fire, however it is.
What am I missing?
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;
}
}
Note - This is question is kind of a 'fork' from Executing a command from another command. I believe that this is more the core issue.