rxjs最终确定操作员vs tap({finalize:(()=> {}})
A和B之间有任何区别吗?是否有任何情况会与另一种情况不同?
a)
observableHere
.pipe(
finalize(() => {
// Do stuff here
})
)
b)
observableHere
.pipe(
tap({
finalize: () => {
// Do stuff here
})
})
)
Is there any difference between A and B? Are there any cases where one would behave differently than the other?
A)
observableHere
.pipe(
finalize(() => {
// Do stuff here
})
)
B)
observableHere
.pipe(
tap({
finalize: () => {
// Do stuff here
})
})
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TAP可以让您在可观察到的各种排放量产生副作用时,让您进入源可观察的一堆事件
,将它们全部分组在一起的单个
tapobserver
可能会更容易。否则,仅使用最终确定操作员可能会更清楚。他们的行为不应该有所不同。
Tap lets you hook into a bunch of events on the source observable
If you're producing side effects for an observable's various emissions, it might be easier to group them all together in a single
TapObserver
. Otherwise, just using the finalize operator is probably clearer.They shouldn't behave any differently.
在TAP中最终确定对我来说绝对没有意义。
唯一的区别是,它将在最终完成之前调用。
Finalize in tap makes absolutly no sense to me.
The only difference is that it will be called before the final finalize.