@@ -7,7 +7,7 @@ import {listenForHistoryChange} from 'redux-location-state';
77import { YdbEmbeddedAPI } from '../services/api' ;
88
99import { getUrlData } from './getUrlData' ;
10- import { rootReducer } from './reducers' ;
10+ import combinedRootReducer , { rootReducer } from './reducers' ;
1111import { api as storeApi } from './reducers/api' ;
1212import { syncUserSettingsFromLS } from './reducers/settings/settings' ;
1313import { UPDATE_REF } from './reducers/tooltip' ;
@@ -54,53 +54,19 @@ export const codeAssistBackend = window.code_assist_backend;
5454
5555const isSingleClusterMode = `${ metaBackend } ` === 'undefined' ;
5656
57- interface BaseStoreOptions {
57+ export interface ConfigureStoreOptions {
58+ aRootReducer ?: Reducer ;
5859 singleClusterMode ?: boolean ;
5960 api ?: YdbEmbeddedAPI ;
61+ additionalReducers ?: Record < string , Reducer > ;
6062}
6163
62- interface StoreOptionsWithCustomRootReducer extends BaseStoreOptions {
63- /**
64- * Custom root reducer that completely replaces the default rootReducer.
65- * ⚠️ Cannot be used together with additionalReducers
66- */
67- aRootReducer : Reducer ;
68- /**
69- * @deprecated When using aRootReducer, additionalReducers cannot be used
70- */
71- additionalReducers ?: undefined ;
72- }
73-
74- interface StoreOptionsWithAdditionalReducers extends BaseStoreOptions {
75- /**
76- * @deprecated When using additionalReducers, aRootReducer cannot be used
77- */
78- aRootReducer ?: undefined ;
79- /**
80- * Additional reducers to be merged with the default rootReducer.
81- * ⚠️ Cannot be used together with aRootReducer
82- */
83- additionalReducers : Record < string , Reducer > ;
84- }
85-
86- interface StoreOptionsDefault extends BaseStoreOptions {
87- aRootReducer ?: undefined ;
88- additionalReducers ?: undefined ;
89- }
90-
91- export type ConfigureStoreOptions =
92- | StoreOptionsWithCustomRootReducer
93- | StoreOptionsWithAdditionalReducers
94- | StoreOptionsDefault ;
95-
96- export function configureStore ( options : ConfigureStoreOptions = { } ) {
97- const {
98- aRootReducer,
99- singleClusterMode = isSingleClusterMode ,
100- api = new YdbEmbeddedAPI ( { webVersion, withCredentials : ! customBackend } ) ,
101- additionalReducers = { } ,
102- } = options ;
103-
64+ export function configureStore ( {
65+ aRootReducer,
66+ singleClusterMode = isSingleClusterMode ,
67+ api = new YdbEmbeddedAPI ( { webVersion, withCredentials : ! customBackend } ) ,
68+ additionalReducers = { } ,
69+ } : ConfigureStoreOptions = { } ) {
10470 ( { backend, basename, clusterName} = getUrlData ( {
10571 singleClusterMode,
10672 customBackend,
@@ -113,12 +79,15 @@ export function configureStore(options: ConfigureStoreOptions = {}) {
11379 if ( aRootReducer ) {
11480 // If custom root reducer is provided, use it
11581 finalReducer = aRootReducer ;
116- } else {
117- // Always create combined reducer from rootReducer and any additional reducers
82+ } else if ( Object . keys ( additionalReducers ) . length > 0 ) {
83+ // If additional reducers are provided, combine them with the default ones
11884 finalReducer = combineReducers ( {
11985 ...rootReducer ,
12086 ...additionalReducers ,
12187 } ) ;
88+ } else {
89+ // Otherwise use the default combined reducer
90+ finalReducer = combinedRootReducer ;
12291 }
12392
12493 const store = _configureStore ( finalReducer , history , { singleClusterMode} , [
0 commit comments