/* ============================================================================ * Copyright (c) Palo Alto Networks * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * ========================================================================== */ import { configureStore, combineReducers } from "@reduxjs/toolkit"; import accept from "@theme/ApiExplorer/Accept/slice"; import auth from "@theme/ApiExplorer/Authorization/slice"; import body from "@theme/ApiExplorer/Body/slice"; import contentType from "@theme/ApiExplorer/ContentType/slice"; import encodingSelection from "@theme/ApiExplorer/EncodingSelection/slice"; import params from "@theme/ApiExplorer/ParamOptions/slice"; import response from "@theme/ApiExplorer/Response/slice"; import schemaSelection from "@theme/ApiExplorer/SchemaSelection/slice"; import server from "@theme/ApiExplorer/Server/slice"; const rootReducer = combineReducers({ accept, contentType, encodingSelection, response, server, body, params, auth, schemaSelection, }); export type RootState = ReturnType; export const createStoreWithState = ( preloadedState: RootState, middlewares: any[] ) => configureStore({ reducer: rootReducer, preloadedState, middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(...middlewares), }); export const createStoreWithoutState = ( preloadedState: {}, middlewares: any[] ) => configureStore({ reducer: rootReducer, preloadedState, middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(...middlewares), }); export type AppDispatch = ReturnType["dispatch"];