blob: bca750a93069d43390db4b9caa8a692cc853f4fa [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
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020017import { createStore, applyMiddleware, compose } from 'redux';
svishnev1eb66b72018-01-11 14:39:45 +020018import Reducers from './Reducers.js';
AviZi280f8012017-06-09 02:39:56 +030019const thunk = store => next => action =>
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020020 typeof action === 'function'
21 ? action(store.dispatch, store.getState)
22 : next(action);
AviZi280f8012017-06-09 02:39:56 +030023
24const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020025export const storeCreator = initialState =>
26 createStore(
27 Reducers,
28 initialState,
29 composeEnhancers(applyMiddleware(thunk))
30 );
Michael Landoefa037d2017-02-19 12:57:33 +020031
32const store = storeCreator();
33
svishnev1eb66b72018-01-11 14:39:45 +020034if (module.hot) {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020035 module.hot.accept('./Reducers.js', () =>
36 store.replaceReducer(require('./Reducers.js').default)
37 );
svishnev1eb66b72018-01-11 14:39:45 +020038}
39
Michael Landoefa037d2017-02-19 12:57:33 +020040export default store;