1 import { combineReducers, configureStore, createListenerMiddleware } from '@reduxjs/toolkit';
3 import { sharedReducers } from '@proton/redux-shared-store';
4 import type { ProtonThunkArguments } from '@proton/redux-shared-store-types';
5 import { ignoredActions, ignoredPaths } from '@proton/redux-shared-store/sharedSerializable';
7 export const extraThunkArguments = {} as ProtonThunkArguments;
9 export const listenerMiddleware = createListenerMiddleware();
11 const rootReducer = combineReducers({
14 export type RootState = ReturnType<typeof rootReducer>;
15 export const setupStore = ({ preloadedState }: { preloadedState: Partial<RootState> }) => {
16 return configureStore({
19 middleware: (getDefaultMiddleware) =>
20 getDefaultMiddleware({
22 ignoredActions: [...ignoredActions],
23 ignoredPaths: [...ignoredPaths],
25 thunk: { extraArgument: extraThunkArguments },
26 }).prepend(listenerMiddleware.middleware),
30 export const extendStore = (newThunkArguments: Partial<ProtonThunkArguments>) => {
31 Object.assign(extraThunkArguments, newThunkArguments);