angular - NGRX Store adapter.updateone 不更改属性以进行更改检

我有以下 reducer :

case ProductionCommentActionTypes.EditCommentSuccess: {
  return adapter.updateOne(action.payload, state);
}

有效负载是以下对象:

{ 
    id: number,
    changes: { 
       id: number;
       avatar: string;
       createdAt: Date;
       createdBy: string;
       body: string;
       discipline: string;
       isConcern: boolean;
       isResolved: boolean;
       plan_Id: number;
       resolution: {
                    id: number;
                    comment_Id: number;
                    avatar: string;
                    createdAt: Date;
                    createdBy: string;
                    body: string;   
                   }
      }
}

不幸的是,当我更新对象时,我可以清楚地看到 action.payload 具有我预期的数据。我检查了 action.payload 和效果:

  @Effect()
  resolveProductionConcernSuccess$: Observable<Action> = this.actions$
  .ofType<ResolveConcernSuccess>(ProductionCommentActionTypes.ResolveConcernSuccess).pipe(
    // Performing a get rather than an edit as the comment should have already 
    // been updated in the service when the resolution was added.
    switchMap(action => this.commentService.getComment(action.payload.comment_Id)), 
          map((comment: any) => {
            comment.updatedBy = "test";
        return new EditCommentSuccess(comment);
      }),
    catchError(err => of(new EditCommentFail(err)))
  );

然而,我从中看到的是:

  this.comments$ = rootStore.select<Comment[]>(fromRoot.getCommentsForSelectedPlan);
this.comments$.subscribe(res => console.log(res));

是旧数据,即使触发了更改。我至少希望看到 updatedBy = "test"。如果我在调试器中单步执行,我还会在 updateOne 之后立即看到有关状态的旧数据。

另一种说法是

      return adapter.updateOne(action.payload, state);

尽管有效载荷中的值正确,但似乎实际上没有改变任何东西。

为什么状态上的属性实际上没有更新?有正确的方法吗?

最佳答案

问题出在 reducer 上。

return adapter.updateOne({ id: action.payload.id, changes: action.payload }, state);

关于angular - NGRX Store adapter.updateone 不更改属性以进行更改检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54558537/

相关文章:

google-apps-script - 调试由发布请求触发的 Google Apps 脚本?

python-3.x - 为什么在 python 中允许 for else

oracle - 使用sqlplus命令行隐藏明文密码

python - 替换 Pandas 数据框中的点

python - MPI4Py comm.Barrier() 没有阻塞 MSMPI?

macos - Homebrew/brew 在安装 gnuplot 时没有选择选项

php - 如何仅在 Laravel 中出现日期时才验证日期

react-native - 如何从 react-native 代码中禁用 Android 默认 "

reactjs - 将映射数据传递给 Material-UI 模态

python - Django 获取一个月中每一天的对象数