NGRX effect only getting final omission from combineLatest

31 Views Asked by At

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

1

There are 1 best solutions below

0
timdeschryver On

NGRX doesn't discard emissions. From the question it seems like you're looking for the merge operator instead of combineLatest. merge will emit each value that is returned.