比如, 下面这段saga代码, 你的协程库准备咋个支持法
function* task1() {
yield delay(1000);
console.log('hello task1');
}
function* task2() {
yield delay(2000);
console.log('hello task2');
}
function* task3() {
yield delay(3000);
console.log('hello task3');
}
function* task() {
yield spawn([task1, task2, task3]);
console.log('hello task');
}
function* uiHandler() {
let task = yield fork(task);
let input = yield take('user-input');
if (input == '1') {
yield cancel(task);
}
}
【 在 hgoldfish (老鱼) 的大作中提到: 】
: 之前我已经看过 rxjs 了,但我不喜欢这种风格的编程方式。
: 上面的讨论已经讲了很多 js 函数式编程的缺陷。最大的缺陷没说,函数式编程晦涩难懂,回调又回调,跟 goto 差不多。
: 奇怪 js 连尾递归、纯函数都没正经地支持,搞函数式编程是几个意思。
: ...................
--
修改:pangwa FROM 101.85.232.*
FROM 101.85.232.*