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

主宰稳场 提交于 2019-12-01 06:50:05
Ritwick Dey

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()
           )
       })

      );
    }

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()
        );
      })
    );

}

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!