From 67254dae293abee3a42b27663a3ef7e4b9eeae6a Mon Sep 17 00:00:00 2001 From: markostanimirovic Date: Mon, 24 Oct 2022 13:54:56 +0200 Subject: [PATCH] feat(store): make reducers arg of StoreModule.forRoot optional --- modules/store/src/provide_store.ts | 9 ++++++--- modules/store/src/store_module.ts | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/store/src/provide_store.ts b/modules/store/src/provide_store.ts index 682a6deedf..b136985c3a 100644 --- a/modules/store/src/provide_store.ts +++ b/modules/store/src/provide_store.ts @@ -114,8 +114,11 @@ export function provideState( } export function _provideStore( - reducers: ActionReducerMap | InjectionToken>, - config: RootStoreConfig + reducers: + | ActionReducerMap + | InjectionToken> + | Record = {}, + config: RootStoreConfig = {} ): Provider[] { return [ { @@ -211,7 +214,7 @@ export function provideStore( config?: RootStoreConfig ): EnvironmentProviders { return makeEnvironmentProviders([ - ..._provideStore(reducers ?? ({} as ActionReducerMap), config ?? {}), + ..._provideStore(reducers, config), ENVIRONMENT_STORE_PROVIDER, ]); } diff --git a/modules/store/src/store_module.ts b/modules/store/src/store_module.ts index ab36ba391c..1f750bd026 100644 --- a/modules/store/src/store_module.ts +++ b/modules/store/src/store_module.ts @@ -81,12 +81,12 @@ export class StoreFeatureModule implements OnDestroy { @NgModule({}) export class StoreModule { static forRoot( - reducers: ActionReducerMap | InjectionToken>, + reducers?: ActionReducerMap | InjectionToken>, config?: RootStoreConfig ): ModuleWithProviders { return { ngModule: StoreRootModule, - providers: [..._provideStore(reducers, config ?? {})], + providers: [..._provideStore(reducers, config)], }; }