Why Observable was subscribed more then once

878 views Asked by At

Observable only can be subscribed by one observer . Subject allows values to be multicasted to many Observers but in this example why foo was subscribed twice? Thank you!

enter image description here

1

There are 1 answers

0
user3743222 On

Well foo is subscribed twice because you subscribe to it twice. It is a typical confusion for people starting with Rxjs. Subscribing any number of times to certain type of observables (called cold observables), will lead you to repeating the exact same process, which is what is happening here. To get a better understanding of the matter, you can refer to the question which has been dealt here : Hot and Cold observables : are there 'hot' and 'cold' operators?