0

在本例中,如何在不使用and store.select方法的情况下从ngrx 存储中获取状态?reselect createSelector

export const getBookCollection = createSelector(getBookEntities, getCollectionBookIds, (entities, ids) => { return ids.map(id => entities[id]); });

constructor(store: Store<fromRoot.State>) { this.books$ = store.select(fromRoot.getBookCollection); }

4

1 回答 1

1

仅使用 store.select 您可以执行以下操作:

export const getBooksCollection = (state: State) => {
    const ids = state.collection.ids;
    const entities = state.books.entities;
    return ids.map(id => entities[id]);
}

constructor(store: Store<fromRoot.State>) {
    this.books$ = store.select(fromRoot.getBookCollection);
}
于 2017-06-27T11:39:06.290 回答