如何在不使用此store.select中的reselect createSelector
和example方法的情况下从 ngrx商店获取状态?
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);
}
答案 0 :(得分: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);
}