I must be doing something wrong as I cannot get a ReactiveCommand to enable at a later point in time. When I set the can execute IObservable to something that evaluates to false a lot to begin with, will never enable the bound button when the IObservable<bool> eventually returns true.
Simply I have the following simple command setup.
var canApprove = this.WhenAny(x => x.CurrentJobStatus, x => x.JobId, (status, jobId) => status.Value == JobStatus.AwaitingApproval.Description && jobId.Value != Guid.Empty);
this.ApproveCommand = ReactiveCommand.CreateAsyncTask(canApprove, ApproveJob);
With the following properties on the ReactiveObject view model
public Guid JobId
{
get { return _jobId; }
set { this.RaiseAndSetIfChanged(ref _jobId, value); }
}
public string Status
{
get { return _status; }
set { this.RaiseAndSetIfChanged(ref _status, value); }
}
When I subscribe to the canApprove observable, I see that it does eventually return true. However, when that happens the CanExecuteChanged event is not raised.
canApprove.Subscribe(b => Debug.WriteLine("CanApprove: {0}", b));
With this subscription I normally see the following output and a disabled button:
CanApprove: False
CanApprove: False
CanApprove: True
I have substituted the canApprove observable for Observable.Return(true) to bypass for now, and it disables while running async no problem.
This is proving to be a bit of a show stopper for me.