0

Looking at many examples for ReactiveUI ReactiveCommands, the code looks something like

Delete = ReactiveCommand.CreateAsyncObservable(x => DeleteImpl());
Delete.IsExecuting.ToProperty(this, x => x.IsDeleting, out _isDeleting);
Delete.ThrownExceptions.Subscribe(ex => this.Log().ErrorException("Something went wrong", ex));

I am attempting to use CreateAsyncTask instead of CreateAsyncObservable

Delete = ReactiveCommand.CreateAsyncTask(x => DeleteImpl());
Delete.IsExecuting.ToProperty(this, x => x.IsDeleting, out _isDeleting);
Delete.ThrownExceptions.Subscribe(ex => this.Log().ErrorException("Something went wrong", ex));

The Delete command is bound to a WPF button.

With the CreateAsyncObservable, the button is enabled after recovery from the Error.

With the CreateAsyncTask, the button is disabled.

Beyond using CreateAsyncObservable (the logic is already written as async methods), how would I re-enable the button after the error?

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
James Bradt
  • 564
  • 5
  • 11

1 Answers1

0

the called method signature that I was using was causing the issue.

    private Task<Unit> DeleteImpl()
    {
        throw new NotImplementedException();
    }

was missing the async keyword

changing the method to

    private async Task<Unit> DeleteImpl()
    {
        throw new NotImplementedException();
    }
James Bradt
  • 564
  • 5
  • 11