Nesting StoreModule.forFeature() reducers in ngrx4

1.5k views Asked by At

Given the following in ngrx4 that works:

@NgModule(
    {
      imports: [
        CommonModule,

        StoreModule.forFeature(
            'clerkingData',
            {
              appetite: appetiteDataReducer,
              bleeding: bleedingDataReducer
            } ),

        StoreModule.forFeature(
            'clerkingUi',
            {
              appetite: appetiteUiReducer
            } )
      ],
      exports: [ ...modules ],
      declarations:
          [ ...components ],
      providers:
          [ ]
    } )
export class ClerkingModule {
}

... Why the following does NOT. (Only 'clerking' is seen in the Devtool)

@NgModule(
    {
      imports: [
        CommonModule,

        StoreModule.forFeature(
            'clerking',
            {
              clerkingData: {
                appetite: appetiteDataReducer,
                bleeding: bleedingDataReducer
              },

              clerkingUi: {
                appetite: appetiteUiReducer
              }
            } )
      ],
      exports: [ ...modules ],
      declarations:
          [ ...components ],
      providers:
          [ ]
    } )

export class ClerkingModule {
}

Thanks

1

There are 1 answers

0
amu On

I don´t think the 2nd argument (ActionReducerMap) of StoreModule.forFeature supports nested reducers.

See this issue in @ngrx/store repo. Although ngrx4 came out after this issue was created, I think it´s still relevant.