blob: bafef7dcd64d7f48e4146e96e24ca7a2a02ecfaa [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
2 * Copyright © 2016-2017 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
Michael Landoefa037d2017-02-19 12:57:33 +02004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
svishnev1eb66b72018-01-11 14:39:45 +02007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Michael Landoefa037d2017-02-19 12:57:33 +020010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
svishnev1eb66b72018-01-11 14:39:45 +020012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Michael Landoefa037d2017-02-19 12:57:33 +020015 */
16
svishnev1eb66b72018-01-11 14:39:45 +020017import {createStore, applyMiddleware, compose} from 'redux';
18import Reducers from './Reducers.js';
AviZi280f8012017-06-09 02:39:56 +030019const thunk = store => next => action =>
20 typeof action === 'function' ?
21 action(store.dispatch, store.getState) :
22 next(action);
Michael Landoefa037d2017-02-19 12:57:33 +020023
AviZi280f8012017-06-09 02:39:56 +030024
25const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
svishnev1eb66b72018-01-11 14:39:45 +020026export const storeCreator = (initialState) => createStore(Reducers, initialState, composeEnhancers(applyMiddleware(thunk)));
AviZi280f8012017-06-09 02:39:56 +030027
Michael Landoefa037d2017-02-19 12:57:33 +020028
29const store = storeCreator();
30
svishnev1eb66b72018-01-11 14:39:45 +020031if (module.hot) {
32 module.hot.accept('./Reducers.js', () =>
33 store.replaceReducer(require('./Reducers.js').default)
34 );
35}
36
Michael Landoefa037d2017-02-19 12:57:33 +020037export default store;