-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(*): utilize rxjs(5.5 and above) lettable operators #35
Conversation
import { debounceTime } from 'rxjs/operators/debounceTime' | ||
import { map } from 'rxjs/operators/map' | ||
import { mergeMap } from 'rxjs/operators/mergeMap' | ||
import { publishReplay } from 'rxjs/operators/publishReplay' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publishReplay(1).refCount()
好像可以被换成 shareReplay(1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Brooooooklyn shareReplay 的区别是出错了之后可以 retry,继续广播接下来可能成功生成的值是吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shareReplay
只是 publishReplay + refCount
的语法糖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Brooooooklyn ReactiveX/rxjs#453 ,好几遍都没看下来@~@
好像是最终 benlesh 接受了 stalz 和 mattpodwysocki 要 fork rxjs 的威胁,放弃对 ReplaySubject 语义的调整,另找办法,不通过 multicast + replaysubject 的办法,而是直接手写一个支持广播及回放功能,又支持 retry 的操作符(可能后来就成了新版的 shareReplay,里面手动使用 ReplaySubject 而不用 multicast)。
不过这两者的确是有不同的,publishReplay(1).refCount() 不能 retry,shareReplay(1) 可以。
看样子是用 shareReplay 比较好了 :)
@Brooooooklyn 谢谢!这个我代码才大致改好,想再看看对打包的影响(或者有什么需要调整优化的地方)。代码修改上,你觉得大致可以吗?使用 pipe 的例子我看得并不多,所以不确定对不对。 |
resolve conflict |
目的: - 更清晰地表达一些读入流、输出流的操作,并帮助进一步提取其中的纯函数; - 通过 pipe 方法组合纯函数,令流管理更像搭积木; - 令每个模块各自对 rxjs 操作符的依赖更清晰。
9cb46a3
to
6d1da59
Compare
@Brooooooklyn resolve 掉了,谢谢 🙏 |
目的: