簡體   English   中英

清除metareducer中的存儲后的ngrx鏈操作

[英]ngrx chain action after clearing the store in metareducer

在metareducer內部的應用程序中,我將在觸發特定操作后清除商店。 此操作只是導航到主頁。 問題是我無法在與此操作鏈接的效果內生成新令牌,因為此功能已將其清除:

  return function (state: AppState, action: Action): AppState {
    if (action.type === OfferActionTypes.GoToBaseInfoPage) {
      state = undefined;
    }
    return reducer(state, action);
  };
}

我試圖在導航后將一個動作鏈接到相關效果中,但是它不起作用:

  navigateToIndex$ = this.actions$.pipe(
    ofType(fromOfferAction.OfferActionTypes.GoToBaseInfoPage),
    tap (() => this._router.navigate(['', this.currentLang]) ),
    map(() => this._store.dispatch(new AuthenticationCustomTokenRequested()))
   );

在導航和清除完成之后,是否可以啟動操作以獲取新令牌?

謝謝

1-使用效果在注銷和導航后調度新操作(例如NEW_ACTION)

 @Effect()
  logout$ = this.actions.ofType(fromActions.LOGOUT).pipe(
    switchMap(() =>
      fromPromise(this.service.signOut()).pipe(
        map(() => new NewAction()),
        catchError(err =>
          of(new AuthError(err)))
        )
      )
    )
  );

2-從更新您的代碼

    if (action.type === OfferActionTypes.GoToBaseInfoPage) {

    if (action.type === OfferActionTypes.NEW_ACTION) {

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM