rxjs中的final和finalize有什么区别 [英] What is the difference between finally and finalize in rxjs
问题描述
我正在使用RxJS
,我可以看到RxJS 5.5.2
中有2个功能可用.是.finally
是否将被移除并且将其放置在病房中pipe()
的pipe()
侧,是原因还是有其他变化?
I am using RxJS
and I can see there are 2 function in RxJS 5.5.2
available. Is the .finally
will be removed and it will be placed in side pipe()
from RxJS 6.0.0
on wards is the reason or there are any other changes?
它们都一样吗,现在最后的呼叫在pipe()
内部?
Are they both same and now final call is inside pipe()
?
还是它们有显着差异?
method()
.pipe(
finalize(() => {
// do some operation
})
)
最终
method()
.finally(() => {
// do your operation
})
推荐答案
两者都是相同的功能,一旦可观察性完成,两者都执行相同的调用操作,但是区别在于您使用的是哪个版本的rxjs
Both are same functionality wise both does same operation of calling once observable is completed but difference is which version of rxjs you are using
在v5.5之前,它最终被称为
Before v5.5 it is been called as finally
从v5.5起,由于引入了可操作的管道运算符(有助于更好地摇晃树),因此将其重命名为finalize(由于关键字限制).有关更多信息,请检查此链接
From v5.5 it is renamed to finalize(due to keyword restriction), because of the introduction to pipeable Operators which helps better tree shaking. For more info please check this link
这篇关于rxjs中的final和finalize有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!