blob: db47650723e8f4fe1fa4a4a331167b14e62e4f41 [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
svishnev7c727c12018-05-24 13:20:51 +03002 * Copyright © 2016-2018 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';
svishnevea5e43c2018-04-15 09:06:57 +030019import filterUpdater from 'sdc-app/onboarding/onboard/filter/FilterMiddleware.js';
svishnev7c727c12018-05-24 13:20:51 +030020import notifications from 'nfvo-components/notification/NotificationsMiddleware.js';
svishnevea5e43c2018-04-15 09:06:57 +030021
AviZi280f8012017-06-09 02:39:56 +030022const thunk = store => next => action =>
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020023 typeof action === 'function'
24 ? action(store.dispatch, store.getState)
25 : next(action);
AviZi280f8012017-06-09 02:39:56 +030026
27const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
svishnevea5e43c2018-04-15 09:06:57 +030028
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020029export const storeCreator = initialState =>
30 createStore(
31 Reducers,
32 initialState,
svishnev7c727c12018-05-24 13:20:51 +030033 composeEnhancers(applyMiddleware(thunk, filterUpdater, notifications))
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020034 );
Michael Landoefa037d2017-02-19 12:57:33 +020035
36const store = storeCreator();
37
svishnev1eb66b72018-01-11 14:39:45 +020038if (module.hot) {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020039 module.hot.accept('./Reducers.js', () =>
40 store.replaceReducer(require('./Reducers.js').default)
41 );
svishnev1eb66b72018-01-11 14:39:45 +020042}
43
Michael Landoefa037d2017-02-19 12:57:33 +020044export default store;