Skip to content

Commit

Permalink
feat(store): make reducers arg of StoreModule.forRoot optional (#3632)
Browse files Browse the repository at this point in the history
  • Loading branch information
markostanimirovic authored Oct 28, 2022
1 parent 24c086f commit e5177aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions modules/store/src/provide_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ export function provideState<T, V extends Action = Action>(
}

export function _provideStore<T, V extends Action = Action>(
reducers: ActionReducerMap<T, V> | InjectionToken<ActionReducerMap<T, V>>,
config: RootStoreConfig<T, V>
reducers:
| ActionReducerMap<T, V>
| InjectionToken<ActionReducerMap<T, V>>
| Record<string, never> = {},
config: RootStoreConfig<T, V> = {}
): Provider[] {
return [
{
Expand Down Expand Up @@ -211,7 +214,7 @@ export function provideStore<T, V extends Action = Action>(
config?: RootStoreConfig<T, V>
): EnvironmentProviders {
return makeEnvironmentProviders([
..._provideStore(reducers ?? ({} as ActionReducerMap<T, V>), config ?? {}),
..._provideStore(reducers, config),
ENVIRONMENT_STORE_PROVIDER,
]);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/store/src/store_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export class StoreFeatureModule implements OnDestroy {
@NgModule({})
export class StoreModule {
static forRoot<T, V extends Action = Action>(
reducers: ActionReducerMap<T, V> | InjectionToken<ActionReducerMap<T, V>>,
reducers?: ActionReducerMap<T, V> | InjectionToken<ActionReducerMap<T, V>>,
config?: RootStoreConfig<T, V>
): ModuleWithProviders<StoreRootModule> {
return {
ngModule: StoreRootModule,
providers: [..._provideStore(reducers, config ?? {})],
providers: [..._provideStore(reducers, config)],
};
}

Expand Down

0 comments on commit e5177aa

Please sign in to comment.