0
votes

I'm working on an e-commerce Angular 6 app using ngrx store (plus the router, router-store and effects modules).

This is my first experience with ngrx, and so far, everything has been going rather smoothly: I have developed several ngrx feature, each one with their respective State and reducer, effects, models and actions.

Only this time, I cannot figure out what I have done wrong. For my last feature, it looks like none of the actions are going through its reducer. The only action it catches is one that has type '@ngrx/store/init'.

Here's the reducer code:

export function reducer(state = initialState, action: ItemCategoryActions): State {
  console.warn('item-category', action.type);
  switch (action.type) {
    case ItemCategoryActionTypes.LoadItemCategories: {
      return state;
    }

    case ItemCategoryActionTypes.LoadItemCategoriesComplete: {
      return { categories: (<LoadItemCategoriesComplete>action).payload.items};
    }

    default:
      return state;
  }
}

I will not reproduce all my code here, as it is your typical ngrx boilerplate, but let me assure you that I have added the reducer to the root reducer map, that I have imported the effects, and that I have made sure that the actions are properly typed, etc.

The log trace of running my code is given below:

enter image description here

As you can see, the only reducer that catches the @ngrx/store/init action is my new item-category reducer, and it doesn't catch any other action.

All my other reducers are working as expected.

At this point, I have run out of hypotheses, so any clues as to how to debug this puzzle will be appreciated.

1

1 Answers

1
votes

Found it! There was a leftover from a previous experiment in my app.module

StoreModule.forFeature('itemCategory', fromItemLevel.reducer),

This was obviously creating a confusing mess...