ReactiveCommand.CreateAsyncTask 的 ReactiveUI 异常句柄恢复
ReactiveUI exception handle recovery for ReactiveCommand.CreateAsyncTask
查看 ReactiveUI
ReactiveCommands
的许多示例,代码看起来像
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));
我正在尝试使用 CreateAsyncTask
而不是 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));
Delete command
绑定到 WPF 按钮。
使用 CreateAsyncObservable
,从错误中恢复后启用按钮。
使用 CreateAsyncTask
,按钮被禁用。
除了使用CreateAsyncObservable
(逻辑已经写成异步方法),错误后如何重新启用按钮?
我使用的调用方法签名导致了问题。
private Task<Unit> DeleteImpl()
{
throw new NotImplementedException();
}
缺少 async
关键字
将方法更改为
private async Task<Unit> DeleteImpl()
{
throw new NotImplementedException();
}
查看 ReactiveUI
ReactiveCommands
的许多示例,代码看起来像
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));
我正在尝试使用 CreateAsyncTask
而不是 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));
Delete command
绑定到 WPF 按钮。
使用 CreateAsyncObservable
,从错误中恢复后启用按钮。
使用 CreateAsyncTask
,按钮被禁用。
除了使用CreateAsyncObservable
(逻辑已经写成异步方法),错误后如何重新启用按钮?
我使用的调用方法签名导致了问题。
private Task<Unit> DeleteImpl()
{
throw new NotImplementedException();
}
缺少 async
关键字
将方法更改为
private async Task<Unit> DeleteImpl()
{
throw new NotImplementedException();
}