I love rxjs… When I first started to use Angular, I tried to avoid it as most as possible (mostly because I really had difficulties to wrap my head around it) but now, I can’t imagine making any project without it.

However, as with every technology or framework, misusing it can have nasty consequences like memory leaks, application slowness or just undesired behaviors.

According to me, the most difficult concept in “rxjs” lies in higher order observables. For those who don’t know what that it is, it’s simply an observable that returns another one. Some examples of these ones would be “mergeMap”, “switchMap”, “exhaustMap”, etc…

I read some (really well written) articles about the differences between the aforementioned operators and I thought I understood the difference pretty well but today, I figured out the hard way that I didn’t. This article will simply highlight the trap I’ve fallen into for you not to do the same.

#angular #rxjs #programming #javascript

Avoid Memory Leaks and Unwanted Behavior when using RxJS mergeMap
2.95 GEEK