ngrx将迁移v2迁移到v4

时间:2017-12-01 07:59:05

标签: angular ngrx ngrx-store ngrx-store-4.0

我正在考虑使用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冲突。您   应该从你的项目中删除它。

所以当我删除导入&#39; @ngrx / core / add / operator / select&#39;我得到了很多&#34; Property&#39; select&#39;在类型&#39; Observable&#39;。

上不存在

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

0 个答案:

没有答案
相关问题