1

我正在考虑升级一个使用ngrx v2的相当大的角度应用程序。我们的减速器,尤其是选择器看起来就像这个仓库当时所做的那样:https ://github.com/ngrx/example-app/blob/05be2b0c1dd1b1d522adb796bd4c1fce2cc5b366/src/app/reducers/books.ts 。

import '@ngrx/core/add/operator/select';

export function getBookEntities(state$: Observable<State>) {
  return state$.select(state => state.entities);
}

export const getBookCollection = function (state$: Observable<State>) {
  return combineLatest<{ [id: string]: Book }, string[]>(
    state$.let(getBookEntities),
    state$.let(getCollectionBookIds)
  )
  .map(([ entities, ids ]) => ids.map(id => entities[id]));
};

然后使用组件中的数据:

this.books$ = store.let(fromRoot.getBookCollection);

迁移指南还说:

@ngrx/core 不再需要,并且可能与 @ngrx/store 冲突。您应该将其从您的项目中删除。

因此,当我删除导入'@ngrx/core/add/operator/select'时,我会得到大量的“属性'select'在'Observable'类型上不存在。

如果我不想引入示例应用程序正在使用的重新选择,推荐的迁移路径是什么?

4

0 回答 0