问题
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?
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?
回答1:
The compared behavior of closed
and isStopped
can be seen in terms of resultant values after each operation:
- On error:
closed
:false
isStopped
:true
.
- If Subject gets completed:
closed
:false
isStopped
:true
.
- If unsubscribed:
closed
:true
isStopped
:true
This is non-exhaustive just show the commons scenarios.
来源:https://stackoverflow.com/questions/52561728/what-is-the-difference-between-the-isstopped-and-closed-property-of-the-subject