问题描述
Subject
类有 2 个属性 closed
和 isStopped
.我知道可以使用 closed 来检查 Subject
是否仍然可以订阅,但是 isStopped
究竟应该用于什么?
The class Subject
has 2 properties closed
and isStopped
. I know that closed can be used to check whether the Subject
can still be subscribed to, but what should isStopped
be used for exactly?
我问这个是因为我试图找到一种方法来知道 BehaviourSubject 的下一个操作何时完成.我可以为此使用 isStopped 还是用于其他用途?
I am asking this because i am trying to find a way to know when a next operation of a BehaviourSubject is completed. Can i use isStopped for that or is it used for something else?
推荐答案
closed
和 isStopped
的比较行为可以从每次操作后的结果值来看:
The compared behavior of closed
and isStopped
can be seen in terms of resultant values after each operation:
- 出错:
关闭
:false
isStopped
:true
.
关闭
:false
isStopped
:true
.
关闭
:true
isStopped
:true
这并非详尽无遗,仅展示公共场景.
This is non-exhaustive just show the commons scenarios.
这篇关于Subject 类的 isStopped 和 closed 属性有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!