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

前端 未结 2 1571
故里飘歌
故里飘歌 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 02:58

    Thanks to @Sajeetharan by looking to this url ended up using exhaustMap

      resolve() {
        return this.actions$.pipe(
          ofActionSuccessful(LoadOnPremHostSuccess),
          exhaustMap(() => {
            return forkJoin(
              this.getData1(),
               this.getData2(),
               this.getData3()
            );
          })
        );
    

    }

    0 讨论(0)
  • 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()
               )
           })
    
          );
        }
    
    0 讨论(0)
提交回复
热议问题