pixelplanet/src/store/storeWin.js

45 lines
782 B
JavaScript
Raw Normal View History

2022-08-17 19:02:50 +00:00
/*
* redux store for windows / popups
*/
/* eslint-disable no-console */
import {
applyMiddleware, createStore, combineReducers,
2022-08-17 19:02:50 +00:00
} from 'redux';
import thunk from 'redux-thunk';
import { persistStore } from 'redux-persist';
/*
* reducers
*/
import sharedReducers from './sharedReducers';
import canvas from './reducers/canvas';
import win from './reducers/win';
/*
* middleware
*/
import parent from './middleware/parent';
2022-08-17 19:02:50 +00:00
const reducers = combineReducers({
...sharedReducers,
canvas,
win,
});
const store = createStore(
reducers,
applyMiddleware(
thunk,
parent,
2022-08-17 19:02:50 +00:00
),
);
export const persistor = persistStore(store, {}, () => {
window.addEventListener('message', store.dispatch);
store.dispatch({ type: 'HYDRATED' });
});
2022-08-17 19:02:50 +00:00
export default store;