Answer the question
In order to leave comments, you need to log in
Why is takeUntil for unsubscribing an Observable better placed at the end of a pipe?
I think many people know about the way to unsubscribe from an Observable subscription, by creating a field of the Subject type (for example, with the name unsubscribe $) and in the Angular component in ngOnDestroy calling the next() and complete() methods for this field, as well as using takeUntil (unsubscribe $) to unsubscribe.
Actually, why does takeUntil(unsubscribe$) need to be used at the end of the list of operators in pipe()?
Answer the question
In order to leave comments, you need to log in
Because a completed observable can be switched to another one that won't complete.
For the same reason, you need to unsubscribe from http, a one-time request can be switched to another one and you can’t follow it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question