1- import { combineReducers , configureStore as configureReduxStore } from '@reduxjs/toolkit' ;
1+ import { configureStore as configureReduxStore } from '@reduxjs/toolkit' ;
22import type { Action , Dispatch , Middleware , Reducer , UnknownAction } from '@reduxjs/toolkit' ;
33import type { History } from 'history' ;
44import { createBrowserHistory } from 'history' ;
@@ -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 rootReducer from './reducers' ;
1111import { api as storeApi } from './reducers/api' ;
1212import { syncUserSettingsFromLS } from './reducers/settings/settings' ;
1313import { UPDATE_REF } from './reducers/tooltip' ;
@@ -54,70 +54,18 @@ export const codeAssistBackend = window.code_assist_backend;
5454
5555const isSingleClusterMode = `${ metaBackend } ` === 'undefined' ;
5656
57- interface BaseStoreOptions {
58- singleClusterMode ?: boolean ;
59- api ?: YdbEmbeddedAPI ;
60- }
61-
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-
57+ export function configureStore ( {
58+ aRootReducer = rootReducer ,
59+ singleClusterMode = isSingleClusterMode ,
60+ api = new YdbEmbeddedAPI ( { webVersion, withCredentials : ! customBackend } ) ,
61+ } = { } ) {
10462 ( { backend, basename, clusterName} = getUrlData ( {
10563 singleClusterMode,
10664 customBackend,
10765 } ) ) ;
10866 const history = createBrowserHistory ( { basename} ) ;
109- let finalReducer : Reducer ;
110-
111- if ( aRootReducer ) {
112- finalReducer = aRootReducer ;
113- } else {
114- finalReducer = combineReducers ( {
115- ...rootReducer ,
116- ...additionalReducers ,
117- } ) ;
118- }
11967
120- const store = _configureStore ( finalReducer , history , { singleClusterMode} , [
68+ const store = _configureStore ( aRootReducer , history , { singleClusterMode} , [
12169 storeApi . middleware ,
12270 ] ) ;
12371 listenForHistoryChange ( store , history ) ;
0 commit comments