svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016-2017 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 3 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 4 | * 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 |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 12 | * 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 Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 17 | import {createStore, applyMiddleware, compose} from 'redux'; |
| 18 | import Reducers from './Reducers.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 19 | const thunk = store => next => action => |
| 20 | typeof action === 'function' ? |
| 21 | action(store.dispatch, store.getState) : |
| 22 | next(action); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 23 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 24 | |
| 25 | const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 26 | export const storeCreator = (initialState) => createStore(Reducers, initialState, composeEnhancers(applyMiddleware(thunk))); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 27 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 28 | |
| 29 | const store = storeCreator(); |
| 30 | |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 31 | if (module.hot) { |
| 32 | module.hot.accept('./Reducers.js', () => |
| 33 | store.replaceReducer(require('./Reducers.js').default) |
| 34 | ); |
| 35 | } |
| 36 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 37 | export default store; |