I read the documentation of switchMap and map, but I still don\'t completely understand the difference. Are there some cases where it does not make a difference at all?
Both operators are different.
switchMap: Maps values to observable. Cancels the previous inner observable.
Eg:
fromEvent(document, 'click')
.pipe(
// restart counter on every click
// First click: 0, 1, 2...
// Second click: cancels the previous interval and starts new one. 0, 1, 2...
switchMap(() => interval(1000))
)
.subscribe(console.log);
map: Add projection with each value.
Eg:
//add 10 to each value
const example = source.pipe(map(val => val + 10));