How to return a `forkJoin` observable when piping the operators

前端 未结 2 1573
故里飘歌
故里飘歌 2021-01-03 02:22

Before I had this resolver that just worked fine:

resolve() {
    return forkJoin(
        this.getData1(),
        this.getData2(),
        this.getData3()
         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 03:13

    Use exhaustMap operator. It maps to inner observable, ignore other values until that observable completes

    import { forkJoin } from 'rxjs';
    import { exhaustMap } from 'rxjs/operators';
    
    resolve() {
        return this.actions$
          .pipe(
            ofActionSuccessful(SomeSctonSuccess),
            exhaustMap(() => {
             return forkJoin(
                 this.getData1(),
                 this.getData2(),
                 this.getData3()
               )
           })
    
          );
        }
    

提交回复
热议问题