DEV Community

Cover image for About switchMap and friends

About switchMap and friends

Jan-Niklas Wortmann on July 18, 2019

RxJS comes with more than 100 different operators. SwitchMap is probably the one that is discussed the most often. It's a very powerful operator, b...
Collapse
 
deanius profile image
Dean Radcliffe

I love this Jan! But if you ever wish for the code to be more self-explanatory, I'd love if you'd check out and comment on this follow-up post I made to yours: dev.to/deanius/never-use-the-wrong...

I made this because I found it too hard to communicate successfully saying things like ExhaustMap will ignore notifications between each inner Observable which might lead to a lose of informations. (though I like how you called it "ignore", which I do too!)

Collapse
 
cogoo profile image
C.OG

Interesting regarding the risks of switchMap. I suppose if you are doing server mutations, you'll have to use exhaustMap instead.

Collapse
 
niklas_wortmann profile image
Jan-Niklas Wortmann

Well it depends. If you want to make sure that everything is really send to the server, I'd recommend concatMap. ExhaustMap will ignore notifications between each inner Observable which might lead to a lose of informations. I hope that helps, if not don't hesitate to ask me

Collapse
 
billyjov profile image
Billy Lando

Thanks for the article.. Is there a Way to subscribe only to the latest completed request ?

stackoverflow.com/q/58728646/6432698