1

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?

hazmah0
  • 263
  • 1
  • 4
  • 16
  • You can take a look at https://github.com/ngrx/platform/blob/master/MIGRATION.md for migrating from old version. – Ha Hoang Dec 01 '17 at 08:17
  • I already did. But they don't mention how to migrate selector functions. – hazmah0 Dec 01 '17 at 08:26
  • Have a look at this [**answer**](https://stackoverflow.com/questions/45220561/providing-root-reducer-in-ngrx-store-4-0/45260650#45260650) – Aravind Dec 01 '17 at 08:46
  • 1
    Well yeah, there is no select property on Observable. What do you expect? In the snippet you should change state$: Observable to state$: Store .... – Jota.Toledo Dec 01 '17 at 08:59
  • Sigh...It is quite obvious. Thank you for pointing it out @Jota.Toledo – hazmah0 Dec 02 '17 at 17:55

0 Answers0