NGRX效果-调度的操作未按顺序执行

时间:2019-11-05 11:31:53

标签: angular ngrx ngrx-effects

问题是调度的动作没有按顺序执行。下面是我的代码。 请建议需要进行哪些更改以使分派的动作按顺序执行

@Effect()
  NTSPrintOrder$: Observable<any> = this.actions$.pipe(
    ofType(listOrderActions.NTSPrintAll),
    withLatestFrom(this.store$.select(state => state['listorder'])),
   mergeMap(([action, listOrderState]: any) => {
      let obs =[];
      var orders =  listOrderState.listOrders.filter(x => x.selected)
      orders.forEach(order => {
         obs.push(listOrderActions.editOrder({'payload': {order_number : order.order_number}}))
         obs.push(listOrderActions.loadNTSDocument())
      });

      obs.push(listOrderActions.printNTSDocument())

      return obs;
    })
  )
}

1 个答案:

答案 0 :(得分:0)

您应仅在editOrder内分派NTSPrintAll。然后editOrder的效果将调度loadNTSDocumentloadNTSDocument的效果将调度printNTSDocument