/* eslint-disable no-unused-vars */ import { createStore, applyMiddleware, compose as origCompose, combineReducers, } from 'redux'; import thunk from 'redux-thunk'; import { lazyReducerEnhancer } from 'pwa-helpers/lazy-reducer-enhancer.js'; import app from './reducers/app.js'; import { loadState, saveState } from './localstorage.js'; const compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || origCompose; export const store = createStore( (state, action) => state, loadState(), // If there is local storage data, load it. compose(lazyReducerEnhancer(combineReducers), applyMiddleware(thunk)) ); store.addReducers({ app, }); // This subscriber writes to local storage anytime the state updates. store.subscribe(() => { saveState(store.getState()); });