I have the following code which loops through ids and returns response for each ID separately one by one.
refresh$ = createEffect(() =>
this.actions$.pipe(
ofType(CustomerActions.refresh),
delay(1000),
WithLatestFrom(this.facade.customerIds$),
exhaustMap(([_, customerIds]) =>
merge(
...customerIds.map((id) =>
this.customersService.getCustomer(id).pipe(
map(CustomerActions.getCustomerSuccess),
catchError((err) =>
of(CustomerActions.getCustomerFailed(id, err.message)),
),
),
),
),
),
),
)
I want to combine the response and get all responses together for customerIds.
I tried moving merge first and then mapping the results, but it resulted in multiple success to be called. Any suggestions?