What is the difference between the isStopped and closed property of the Subject class?

筅森魡賤 提交于 2020-05-12 15:48:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!