mergeMap & switchMap
import { from, interval, mergeMap, switchMap, zip } from 'rxjs';
import { map } from 'rxjs/operators';
const getCurrentCity = () => {
/* Produce one value from the array every second. */
return zip(
from(['Strasbourg', 'Paris', 'Lyon']),
interval(1000)
)
.pipe(map(([city]) => city));
};
const getTemperature = city => {
/* Produce the same temperature per city every 500ms. */
return interval(500)
.pipe(map(() => 100 / city.length));
};mergeMap
mergeMapswitchMap
switchMapMis à jour