Skip to content

[Feature Request] Allow for a single reducer to be registered in a feature module #34

@delasteve

Description

@delasteve

Problem:

Currently, you must pass an ActionReducerMap to StoreModule.forFeature(featureName: string, reducers: ActionReducerMap<any, any>). Sometimes, a feature module only needs a single reducer to be registered. By not allowing this, it will add an unnecessary intermediate step to get to the desired state.

Proposal:

Allow for StoreModule.forFeature(featureName: string, reducer: ActionReducer<any, any>).

Current functionality:

State interfaces

export interface PilotsModuleState {
  pilot: PilotState;
}

export interface PilotState {
  pilots: Pilot[]
}

feature.module.ts

imports: [
  ...,
  StoreModule.forFeature('pilotsModule', { pilot: pilotReducer })
]

Feature selectors:

const selectPilotsModule = createFeatureSelector<PilotsModuleState>('pilotsModule');
const selectPilotsState = createSelector(selectPilotsModule, (state: PilotsModuleState) => state.pilot);
const selectPilots = createSelector(selectPilotsState, (state: PilotState) => state.pilots);

Desired functionality:

State interfaces

export interface PilotsModuleState {
  pilots: Pilot[]
}

feature.module.ts

imports: [
  ...,
  StoreModule.forFeature('pilotsModule', pilotReducer)
]

Feature selectors:

const selectPilotsModule = createFeatureSelector<PilotsModuleState>('pilotsModule');
const selectPilots = createSelector(selectPilotsState, (state: PilotsModuleState) => state.pilots);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions