ngrx store migration v2 to v4

454 Views Asked by At

I'm looking into upgrading quite a big angular app which uses ngrx v2. Our reducers, and especially the selectors look like this repo did at the time: 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]));
};

Then to consume the data in a component:

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

The migration guide also says:

@ngrx/core is no longer needed, and can conflict with @ngrx/store. You should remove it from your project.

So when i remove the import '@ngrx/core/add/operator/select' I get tons of "Property 'select' does not exist on type 'Observable'.

Whats the recommended migration path if i don't want to introduce reselect which the example app is using?

0

There are 0 best solutions below