well, sometimes we do not even need to cancel; we just have to discard
previous results. if we had an IO monad that is very restricted like it
is in haskell, such problems may simply disappear.
(i never used rxjs but bacon claimed to be similar so this example is bacon)
pageUrl
.flatMapLatest(routerFunction)
.onValue(page => React.render(dom, page));
when route changes, the stream for previous route may continue to produce
pages, but will be discarded. no need for explicit cancel.
imo what makes streams superior to promises is that they have stricter
combination rules, requires a subscriber to produce side effects, thereby
encouraging programmers to compose everything into a super large stream;
and when we do that, the ability to produce multiple values is naturally
needed.
【 在 facilitator (黄书中自有颜如玉 脸书中自有黄金屋) 的大作中提到: 】
: typescript的async/await也可以throw 不过这代价有点太高了吧
: 上面说的用户初始了动作又无法放弃 通常是造成UI遇到错误的重要原因
--
FROM 49.221.19.*