1

students.reducer.ts

export const StudentsFeatureKey = 'students';

export interface StudentState {
 studentProfile: fromStudProfReducer.StudentProfileState;
 studentAdmin: fromStudAdminReducer.StudentAdminState;
}

export const reducer = combineReducers({
  studentProfile: fromStudProfReducer.Reducer,
  studentAdmin: fromStudAdminReducer.Reducer
});

student-profile.reducer.ts

export interface StudentProfileState extends EntityState<StudentProfileViewModel> {}
export const adapter = createEntityAdapter<StudentProfileViewModel>();
export const initialState: StudentProfileState = adapter.getInitialState();

export const Reducer = createReducer(
 initialState
);

export const {
  selectIds,
  selectEntities,
  selectAll,
  selectTotal,
} = adapter.getSelectors();

student-profile.selectors.ts

export const getStudentsFeatureState = 
  createFeatureSelector<fromStudentsReducer.StudentState>(
  fromStudentsReducer.StudentsFeatureKey
);

THIS SELECTOR IS FAILING --> TypeError: Cannot read property 'map' of undefined

export const selectAllStudentProfiles = createSelector(
  getStudentsFeatureState,
  fromStudProfReducer.selectAll,
  (_, profiles) => profiles
);

student-facade.service.ts

private _testValue = this.store.pipe(
  select(selectAllStudentProfiles),
  tap(profiles => console.log('profiles: ', profiles))
).subscribe();

Thanks for helping

EDIT

selecting the parent feature slice is working just fine, i.e. when I use getStudentsFeatureState.

private _testValue = this.store.pipe(
  select(getStudentsFeatureState),
  tap(state => console.log('state: ', state))
).subscribe();

I'am getting the

enter image description here

Richard77
  • 20,343
  • 46
  • 150
  • 252

0 Answers0