Angular — Three alternatives for unsubscribing observables at ngOnDestroy
--
RxJS is a common library in the world of Angular. If you have been using RxJS for some time, you may have already faced the unsubscription issue. Simply put, after making a subscription, you will always need to unsubscribe at a certain point to avoid memory leaks. We want it to happen during component ngOnDestroy
in most cases. However, managing these subscriptions explicitly for each component could be troublesome and painful. Here I have summarised three alternatives that could help to generalize the unsubscription logic and make…