PromucFlow_constructor/app/client/src/store.ts
Sangeeth Sivan e9d719103c
chore: code split sagas and reducer's index file (#16261)
* chore: code split sagas and reducers index file

* fix: update imports

* chore: remove acl reducers file on ce

* fix: code split reducers properly

* chore: remove unnecessary import

* chore: split root sagas file
2022-08-24 17:46:32 +05:30

53 lines
1.5 KiB
TypeScript

import { reduxBatch } from "@manaflair/redux-batch";
import { createStore, applyMiddleware, compose } from "redux";
import {
useSelector as useReduxSelector,
TypedUseSelectorHook,
} from "react-redux";
import appReducer, { AppState } from "@appsmith/reducers";
import createSagaMiddleware from "redux-saga";
import { rootSaga } from "@appsmith/sagas";
import { composeWithDevTools } from "redux-devtools-extension/logOnlyInProduction";
import * as Sentry from "@sentry/react";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import routeParamsMiddleware from "RouteParamsMiddleware";
const sagaMiddleware = createSagaMiddleware();
const sentryReduxEnhancer = Sentry.createReduxEnhancer({
actionTransformer: (action) => {
if (
action.type === ReduxActionTypes.SET_EVALUATED_TREE ||
action.type === ReduxActionTypes.EXECUTE_PLUGIN_ACTION_SUCCESS
) {
// Return null to not log the action to Sentry
action.payload = null;
}
return action;
},
});
export default createStore(
appReducer,
composeWithDevTools(
reduxBatch,
applyMiddleware(sagaMiddleware, routeParamsMiddleware),
reduxBatch,
sentryReduxEnhancer,
),
);
export const testStore = (initialState: Partial<AppState>) =>
createStore(
appReducer,
initialState,
compose(
reduxBatch,
applyMiddleware(sagaMiddleware, routeParamsMiddleware),
reduxBatch,
),
);
sagaMiddleware.run(rootSaga);
export const useSelector: TypedUseSelectorHook<AppState> = useReduxSelector;