Angular 带效果的无限循环-角度ngrx8

Angular 带效果的无限循环-角度ngrx8,angular,ngrx,ngrx-effects,Angular,Ngrx,Ngrx Effects,有两个问题与此相关…但我经历了所有,但我的问题没有解决。基本上我是一个初学者,所以我无法追踪这个问题 这是我的特效: readMsg$ = createEffect(() => this.actions$.pipe( ofType(readMsg), map(action => action.payload), switchMap((reqPayload: MsgReadRequest) => { return this.httpService.post

有两个问题与此相关…但我经历了所有,但我的问题没有解决。基本上我是一个初学者,所以我无法追踪这个问题

这是我的特效:

readMsg$ = createEffect(() => this.actions$.pipe(
  ofType(readMsg),
  map(action => action.payload),
  switchMap((reqPayload: MsgReadRequest) => {
      return this.httpService.post('api/msgread', reqPayload)
      .pipe(
        map((resp: MsgReadResponse) => resp.message === 'ok' ?
        readMsgSucess({payload: resp}) :
        readMsgFailure({payload: resp}),
        catchError((error: HttpErrorResponse) => of(error.message))
      )
    );
    })
));
以下是我的行动:

export const readMsg  = createAction('[Read] Msg in xl', props<{payload: NewsReadRequest}>());
export const readMsgSucess  = createAction('[Read] Msg in xl', props<{payload: NewsReadResponse}>());
export const readMsgFailure  = createAction('[Read] Msg in xl', props<{payload: NewsResponse}>());
export const htttpError  = createAction('[Read] Msg in xl error', props<{payload: HttpErrorResponse}>());
export const readMsg=createAction('[Read]Msg in-xl',props());
export const readMsgSucess=createAction('[Read]Msg in xl',props());
export const readMsgFailure=createAction('[Read]Msg in xl',props());
export const htttperor=createAction('[Read]Msg in xl error',props());

也许这对你有帮助

readMsg$ = createEffect(() => this.actions$.pipe(
  ofType(readMsg),
  map(action => action.payload),
  switchMap((reqPayload: MsgReadRequest) => 
    this.httpService.post('api/msgread', reqPayload)
      .pipe(
        map((resp: MsgReadResponse) => resp.message === 'ok' ?
        readMsgSucess({payload: resp}) :
        readMsgFailure({payload: resp}),
        catchError((error: HttpErrorResponse) => of(error.message))
      )
    ))
));
一个简单的错误。。 在行动中,我不应该提及同样的声明。我只是改变了下面的行动,现在一切都正常了

export const readMsg=createAction('[Read]Msg in-xl',props());
export const readMsgSucess=createAction('xl success'中的[Read]Msg',props());
export const readMsgFailure=createAction(“[Read]Msg in xl failure”,props());

export const htttperor=createAction('[Read]Msg in xl error',props())尝试删除return以查看它是否适用于you@TonyNgo不,不工作..在删除获取编译问题之后..@TonyNgo感谢Tony的回复..实际上我犯了一个愚蠢的错误,因为发生了无限循环。