import { getMultiplayerConnection } from 'app/multiplayer/Connection' ; import { createMiddleware } from 'app/multiplayer/Middleware' ; import { installStore as installAppStore } from 'app/Store' ; import Redux , { applyMiddleware , compose , createStore } from 'redux' ; import thunk from 'redux-thunk' ; import questIDEApp from './reducers/CombinedReducers' ; declare var window ; declare var require ; declare var module ; export let store ; const appMiddleware = createMiddleware ( getMultiplayerConnection ( ) ) ; const adjustedAppMiddleware = ( { dispatch } ) => { return appMiddleware ( { dispatch , getState : ( ) => { return store . getState ( ) . preview || { } ; } , } ) ; } ; const composeEnhancers = window . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose ; const initialState = { preview : { } } ; const middleware = [ thunk , adjustedAppMiddleware ] ; store = createStore ( questIDEApp , initialState , composeEnhancers ( applyMiddleware ( ... middleware ) ) ) ; installAppStore ( { dispatch : store . dispatch , getState ( ) { return store . getState ( ) . preview || { } ; } , replaceReducer : store . replaceReducer , subscribe : store . subscribe , } ) ; if ( module && module . hot ) { module . hot . accept ( './reducers/CombinedReducers' , ( ) => { const updated = require ( './reducers/CombinedReducers' ) . default ; store . replaceReducer ( updated ) ; } ) ; }