换句话说, 函数式编程定义关系, 而命令式编程定义步骤
集中的逻辑. Rx 自然而然在一处定义逻辑, 避免其他范式逻辑分散在代码库的各个地方....代码实现:
首先 add$, modify$以及 remove$和complete$可以分别使用一个 Subject 对象来表示, 用于接收外部事件....= 'COMPLETE';
const update$ = new Subject();
function add(value: string) {
update$.next(...type: REMOVE_ACTION,
payload: id,
});
}
function complete(id: string) {
update$.next({
type...: COMPLETE_ACTION,
payload: id,
});
}
function modify(id: string, value: string) {
update$.next