Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
delasteve opened this issue Jun 1, 2017 · 0 comments

Comments

@delasteve
Copy link
Contributor

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);
MikeRyanDev added a commit that referenced this issue Jun 11, 2017
Also allows feature modules to declare just one reducer function instead
of a complete action reducer map.

Closes #34
brandonroberts pushed a commit that referenced this issue Jun 12, 2017
Also allows feature modules to declare just one reducer function instead
of a complete action reducer map.

Closes #34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant