`add` Inner Subscriptions to Outer Subscribers to `unsubscribe` in RxJS

Share this video with your friends

Send Tweet

When subscribers create new "inner" sources and subscriptions, you run the risk of losing control of them when the outer subscriber unsubscribes. This is handled easily enough if you use the add method from the Subscriber class to add the "inner" subscription to the Subscriber.

J. Matthew
J. Matthew
~ 5 years ago

Thanks so much for this course. I went through it twice, and it really did a lot to demystify RxJS.

Ningze
Ningze
~ 4 years ago

There is one thing I don't understand. When the inner observable completes, it is still calling the _next() recursively because the buffer length is not zero. It will create a new o$ again, so new values will be thrown out. Why it stops throwing values after you add the innterSubscription ? _next() will get called anyway when the inner observable completes.