Beispiel #1
0
const configureStore = (initialState, resourcePath) => {
  const middleware = [];

  middleware.push(thunk);

  const enhancer = compose(
    applyMiddleware(...middleware),
    electronEnhancer({
      dispatchProxy: a => store.dispatch(a),
    })
  );

  const persistedReducer = persistReducer(persistConfig, rootReducer);
  const store = createStore(persistedReducer, initialState, enhancer);
  const persistor = persistStore(store, null, () => {
    // Destroy any invalid settings that may have made its way into persistant storage
    store.dispatch({
      type: types.RESET_INVALID_SETTINGS
    });
    // Configure localization after the store has rehydrated to get the language from settings
    configureLocalization(resourcePath, store.getState());
  });

  if (module.hot) {
    module.hot.accept('../../reducers', () =>
      store.replaceReducer(require('../../reducers'))); // eslint-disable-line global-require
  }

  return { store, persistor };
};
Beispiel #2
0
export default function configureStore() {
  return createStore(
    reducers,
    compose(
      applyMiddleware(...middlewares),
      electronEnhancer()
    )
  );
}
Beispiel #3
0
function configureStore(initialState, resourcePath) {
  const enhancer = compose(
    applyMiddleware(thunk),
    electronEnhancer({
      dispatchProxy: a => store.dispatch(a)
    })
  );
  const persistedReducer = persistReducer(persistConfig, rootReducer);
  const store = createStore(persistedReducer, initialState, enhancer);
  const persistor = persistStore(store, null, () => {
    // Destroy any invalid settings that may have made its way into persistant storage
    store.dispatch({
      type: types.RESET_INVALID_SETTINGS
    });
    // Configure localization after the store has rehydrated to get the language from settings
    configureLocalization(resourcePath, store.getState());
  });
  return { store, persistor };
}
Beispiel #4
0
import { spawn } from 'child_process';
import { app, BrowserWindow, ipcMain as ipc } from 'electron';
import path from 'path';
import { createStore, applyMiddleware, compose } from 'redux';
import { electronEnhancer } from 'redux-electron-store';
import thunk from 'redux-thunk';
import which from 'which';

import reducer from './js/reducers';

const enhancer = compose(
    applyMiddleware(
        thunk
    ),
    electronEnhancer()
);

const store = createStore(reducer, enhancer); // eslint-disable-line

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;

const startRestAPI = (callback) => {
    // find the conda python and use that to infer the conda bin directory
    // which needs to be reapplied to the front of our path so that subprocess
    // spawns work correctly.
    const python = which.sync('python', { all: true })
                        .find(binaryPath => binaryPath.search('conda') !== -1);
    const condaBin = path.dirname(python);