I am trying to run multiple request in batches of 3 using the windowCount operator and joining the results using the concatMap operator:
import { range, windowCount, map, concatMap, mergeMap } from 'rxjs';
import { ajax } from 'rxjs/ajax';
const ids = range(1, 10);
const result = ids.pipe(
windowCount(3),
concatMap((win) =>
win.pipe(
mergeMap((id) =>
ajax(`https://jsonplaceholder.typicode.com/posts/${id}`).pipe(
map((res) => res.response)
)
)
)
)
);
result.subscribe((x) => console.log(x));
But the concatMap operator sunscribes only to the first window and ignores the rest. This is the result i get:
>> {id: 2, ...}
>> {id: 3, ...}
>> {id: 1, ...}
What's going on?