Javascript 链接ngrx中的两个操作

Javascript 链接ngrx中的两个操作,javascript,angular,redux,rxjs,ngrx,Javascript,Angular,Redux,Rxjs,Ngrx,我有两个相关的动作,应该一个接一个地触发 我想用@effects或reducer来做这件事 在我的slider.component中,我触发第一个父操作 valueChange(event: MatSliderChange) { this.store.dispatch( new SetSelectDateTime({ dateSelect: this.date, timeSelect: event.source.displayValue }) ); } 然后在减速器中 case

我有两个相关的动作,应该一个接一个地触发

我想用@effects或reducer来做这件事

在我的slider.component中,我触发第一个父操作

valueChange(event: MatSliderChange) {
  this.store.dispatch(
    new SetSelectDateTime({ dateSelect: this.date, timeSelect: event.source.displayValue })
  );
}
然后在减速器中

case ESelectDateTimeActionTypes.SetSelectDateTime: {

  return {
    ...state,
    dateTimeSelect: action.payload
  };
}
现在,我应该触发第二个操作,以根据选定的时间获取新的数据 所以我创建了一个效果updateActualTrips

问题是效果从未触发,但选定的时间已更新

更新
我注意到效果是在SetSelectDateTime第一次初始化时触发的

在示例代码中,等待操作ESchedulesActions.GetNextSchedulesByTime没有效果,您等待的唯一其他操作是ESchedulesActions.GetSchedulesByDate和EKpiActions.GetMissionsByStation

您是否缺少实际效果,或者我们没有看到完整的代码?在调度SetSelectDateTime时,代码中没有任何内容会要求API提供新数据


或者,您的意思是,在运行侦听SetSelectDateTime的效果时,ESchedulesActions.GetNextSchedulesByTime从一开始就不会调度到存储?

您的效果类是否已在EffectsModule中注册?看是的,其他的效果在课堂上也起作用了,我用所有的效果类更新了我的问题,那么这里的问题是什么?您的值更改未被触发?
export class SchedulingsEffects {
  constructor(
    private actions$: Actions,
    private apiCallsService: ApiCallsService
  ) {}
  loadSchedulings$ = createEffect(() =>
    this.actions$.pipe(
      ofType(ESchedulesActions.GetSchedulesByDate),
      mergeMap(() =>
        this.apiCallsService.getSchedulings().pipe(
          map(trips => ({ type: ESchedulesActions.GetSchedulesByDateSuccess, payload: trips })),
          catchError(() => EMPTY)
        )
      )
    )
  );

  $LoadKpiMission = createEffect(() =>
    this.actions$.pipe(
      ofType<any>(EKpiActions.GetMissionsByStation),
      mergeMap(action =>
        this.apiCallsService.getKpiMissionByStation(action.payload, '2016-04-18').pipe(
          map(trips => ({ type: EKpiActions.GetMissionsByStationSuccess, payload: trips })),
          catchError(() => EMPTY)
        )
      )
    )
  );
  $updateActualTrips = createEffect(() =>
    this.actions$.pipe(
      ofType<any>(ESelectDateTimeActionTypes.SetSelectDateTime),
      map(action => ({ type: ESchedulesActions.GetNextSchedulesByTime, payload: action.payload }))
    )
  );
}