mergeMap
mergeMap
is a combination of map
+ mergeAll
.
const fetchMovie = (name) => {
return new Prmose((resolve) => {
setTimeout(() => {
resolve({
name
})
}, 2000);
})
}
a$.pipe(
mergeMap((a) => from(fetchMovie(a)))
).subscribe((b) => {
console.log(b);
})
// is exactly the same as
a$.pipe(
map((a) => from(fetchMovie(a))),
mergeAll()
).subscribe((b) => {
console.log(b);
})