I have been doing some tests with ngrx store but having some issues:
mainly around fetching the information from the store.
You can see my code here https://github.com/FabioBiao/ngrxtTest
On the home.component.ts i try to get the contents of the store. However I'm getting a object with the name of the store and inside that object its contents.
store.pipe(select(getCart)).subscribe((data) => {
console.log('load finish on component');
console.log(data);
if (data && data['shop']) {
console.log(data['shop']);
this.items = data['shop'].items;
}
I was expecting to get the content inside the store right away, but instead i need to do data['shop'] to get the store data. What have i missed for this to work in a better way?
I also tried using this
this.getItemsList = store.select(getItemsList);
with this selector:
const shopFeatureState = createFeatureSelector<StoreState>('myshop');
export const getItemsList = createSelector(
shopFeatureState,
state => state.items
);
But its retuning the object store. I need to subscribe to itto get the content inside the store object. Is this also the correct way?
Thanks for the help