I return a combineLatest from my service thats a collection of requests to my backend. I listen to it in my effect via switchMap. The requests work as intended and then when they all complete I get my response in my effect.
What I need however is to listen to the emissions as they happen. I've also tried using zip but no luck. The only emission I get is the final one.
The code is something like this:
// Effect
createEffect(() => {
return this.action$.pipe(
ofType(someAction),
switchMap(action => {
return this.service.doSomething().pipe(
tap(results => ...nothing happens until the end),
map(results => ...do stuff)
)
})
)
});
// Service
public doSomething() {
const requests = someData.map(data => this.http.get(...))
return combineLatest(requests).pipe(
tap(results => // nothing happens here until the end
)
}
Any ideas? It seems like under the hood NGRX is discarding other emissions
NGRX doesn't discard emissions. From the question it seems like you're looking for the
mergeoperator instead ofcombineLatest.mergewill emit each value that is returned.