I have in my ngrx-entity store the prsnls entity well described as array of objects as shown in redux devtool.
I'm able to select all prsnl entities like this:
export const selectAllPrsnls = createSelector(
selectPrsnlState,
prsnlsState => {
const allPrsnls = Object.values(prsnlsState.entities)
return allPrsnls;
}
);
But I'm unable to get a unique prsnl by it's id. This is what I did:
export const selectUniquePrsnls = (id:string) => createSelector(
selectPrsnlState,
prsnlsState => {
const uniquePrsnls = Object.values(prsnlsState.entities[id])
return uniquePrsnls;
}
);
The unique prsnl is not fetched because when I console.log after susbscribing to the createSelector observable, I get undefined in the console. This is how I subscribed to it:
getUniquePersnlValues(id:string){
this.store
.pipe(select(selectUniquePrsnls), map((per) => per))
.subscribe((value: any) => this.uniquePrsnl = value);
console.log('prsnl', this.uniquePrsnl);
}
I think I'm not able to troubleshoot this issue because I don't understand well what does the selectPrsnlState
when creating the selector like on srrenshot:
How can I then get a unique prsnl from the prsnls entities in this situation. Any help is much appreciated. Thanks in advance.