github.com/replicatedhq/ship@v0.55.0/web/init/src/redux/index.js (about)

     1  import { createStore, combineReducers, applyMiddleware, compose } from "redux";
     2  import { createTracker } from "redux-segment";
     3  import thunk from "redux-thunk";
     4  
     5  // Reducers
     6  import DataReducers from "./data";
     7  import UIReducers from "./ui";
     8  
     9  const tracker = createTracker();
    10  
    11  let store;
    12  
    13  export function configureStore(apiEndpoint) {
    14    const appReducer = combineReducers({
    15      data: DataReducers,
    16      ui: UIReducers,
    17      apiEndpoint: () => apiEndpoint
    18    });
    19  
    20    const rootReducer = (state, action) => {
    21      if (action.type === "PURGE_ALL") {
    22        state = undefined
    23      }
    24      return appReducer(state, action);
    25    };
    26  
    27    const hasExtension = window.devToolsExtension;
    28    store = createStore(
    29      rootReducer,
    30      compose(
    31        applyMiddleware(thunk, tracker),
    32        hasExtension ? window.devToolsExtension() : f => f,
    33      ),
    34    )
    35  
    36    return store;
    37  }
    38  
    39  export function getStore() {
    40    return store;
    41  }