Nate May
Nate May

Reputation: 4062

ngrx store is suddenly not loading a State property and its reducer ( Angular Cli)

After some trivial application changes, my ngrx store is suddenly not loading properly. As you can see in the screen shot below, I am getting most of my store properties and those are even loading my api results through their reducers, but I'm missing 1 critical state property uiState.

I've undone my trivial changes and restarted my browser, terminal, cleared my cache and local storage and restarted my computer, but my uiState is not getting added to my store and its reducer is never called. Could this be and Angular Cli or Webpack memory issue? If so how can I clear the memory?

enter image description here

this is what my state should look like:

export interface AppState {
  uiState: UIState;
  foodStaging: $DietEntryMap;
  recipeBuilder: RecipeBuilder;
  dbData: MongoData;
}

and Here is how I compose my reducers:

const reducers = {
  uiState: uiStateReducer,
  recipeBuilder: recipeReducer,
  foodStaging: stagingReducer,
  dbData: dbDataReducer
};

const developmentReducer: ActionReducer<AppState> =
  compose(
    storeFreeze,
    storeLogger(loggerOptions),
    localStorageSync(['dbData'], true),
    combineReducers)
  (reducers);

const productionReducer: ActionReducer<AppState> =
  compose(localStorageSync(['dbData']), combineReducers)(reducers);

export function storeReducer(state: AppState, action: any) {
  if (environment.production) return productionReducer(state, action);
  else return developmentReducer(state, action);
}

And my UiState reducer looks like this:

export function uiStateReducer(state: UIState = INITIAL_UI_STATE, action: UiActions): UIState {
  switch (action.type) {
    // action handlers
  }
}

INITIAL_UI_STATE is valid

Upvotes: 0

Views: 575

Answers (1)

Nate May
Nate May

Reputation: 4062

There was some issue when I tried to import a helper function, from a reducer file, through a barrel, into an Effect service. I just moved the whole function over to the effect and everything worked.

Upvotes: 1

Related Questions