Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

rxjs

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?

like image 637
Maurice Avatar asked Sep 28 '18 19:09

Maurice


People also ask

What is a RxJS subject?

A subject in RxJS is a special hybrid that can act as both an observable and an observer at the same time. This way, data can be pushed into a subject, and the subject's subscribers will, in turn, receive that pushed data.

How do you find the current value of BehaviorSubject?

If you want to have a current value, use BehaviorSubject which is designed for exactly that purpose. BehaviorSubject keeps the last emitted value and emits it immediately to new subscribers. It also has a method getValue() to get the current value.

What is RxJS BehaviorSubject?

BehaviorSubject is a variant of a Subject which has a notion of the current value that it stores and emits to all new subscriptions. This current value is either the item most recently emitted by the source observable or a seed/default value if none has yet been emitted.

What is the best example of the closure property of addition?

The best example of showing the closure property of addition is with the help of real numbers. Since the set of real numbers is closed under addition, we will get another real number when we add two real numbers.

What is the difference between sold and closed real estate?

ANSWER: Real Estate is not considered to be "Sold" until the actual transfer of the property has taken place and consideration has been paid. Once that has taken place, the property is "Closed" and belongs to the new owner. Question: How do I go about getting my real estate license?

What is the difference between Class A and Class B properties?

Class B properties are generally older than Class A properties (up to 30 years old), and feature medium-quality finishes and amenities. These properties often have deferred maintenance issues that the new owner will have to deal with on day one, and may have lower-income tenants.

What is closure property of a set?

Closure Property. In mathematics, a set is closed under an operation when we perform that operation on members of the set, and we always get a set member. Thus, a set either has or lacks closure concerning a given operation.


1 Answers

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.

like image 131
nilsandrey Avatar answered Oct 16 '22 20:10

nilsandrey