summaryrefslogtreecommitdiff
path: root/src/store/configureStore.js
blob: ecd804a22fc95c853117cd126cd4424cffad5a92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {applyMiddleware, compose, createStore} from "redux";
import persistState from "redux-localstorage";
import {createLogger} from "redux-logger";
import createSagaMiddleware from 'redux-saga';
import thunk from "redux-thunk";
import rootSaga from "../api/sagas/index";
import {authRedirectMiddleware} from "../auth/index";
import rootReducer from "../reducers/index";

const sagaMiddleware = createSagaMiddleware();
const logger = createLogger();

export default function configureStore() {
    const store = createStore(
        rootReducer,
        compose(
            persistState("auth"),
            applyMiddleware(
                logger,
                thunk,
                sagaMiddleware,
                authRedirectMiddleware,
            )
        )
    );
    sagaMiddleware.run(rootSaga);

    return store;
}