【发布时间】:2020-09-07 07:49:31
【问题描述】:
解决方案 A)
public ReactiveCommand<Unit, Unit> CommandDoStuff => this._commandDoStuff;
private readonly ReactiveCommand<Unit, Unit> _commandDoStuff;
this._commandDoStuff = ReactiveCommand.CreateFromTask(async () =>
{
//pass in parameters directly, do stuff, handle output maybe with an interaction, return Unit;
var result = await DoStuff(this.Parameter);
SharedInteraction.Handle(result);
return;
});
this._commandDoStuff.Execute().Subscribe();
解决方案 B)
public ReactiveCommand<T, T> CommandDoStuff => this._commandDoStuff;
private readonly ReactiveCommand<T, T> _commandDoStuff;
this._commandDoStuff = ReactiveCommand.CreateFromTask(async (T) =>
{
//do stuff, return T
var result = await DoStuff(T);
return result;
});
this._commandDoStuff.Execute(T).Subscribe(t =>
{
//handle output maybe with an interaction
SharedInteraction.Handle(t);
return;
});
我知道这些是蹩脚的问题,但这是为了避免提出基于意见的问题......
这两种解决方案都“有效”吗?
两种解决方案是否等效?如果不是,有什么区别?
一种解决方案的性能更高吗?
一种解决方案是否比另一种解决方案更频繁地出现错误?
一种解决方案是否比另一种更遵循软件工程范式?
你明白我在问什么! :)
【问题讨论】:
标签: .net architecture software-design reactiveui