samiskin / redux-electron-store

⎋ A redux store enhancer that allows automatic synchronization between electron processes
MIT License
375 stars 32 forks source link

The UI actions of DevTools monitor cannot be apply main process store #6

Closed jhen0409 closed 8 years ago

jhen0409 commented 8 years ago

Renderer

let finalCreateStore = compose(
  applyMiddleware(...middleware),
  electronEnhancer({filter}),
  DevTools.instrument()
)(createStore);

It seems obvious, the UI actions of LogMonitor cannot be apply to main process store, any plans to solve this problem?

samiskin commented 8 years ago

Something along the lines of this is what I did:

let storeEnhancers = compose(
 ...
  applyMiddleware(thunk, logger)
);

if (process.type === 'renderer' && !process.guestInstanceId) {
  let DevTools = require('DevTools');
  storeEnhancers = compose(
    storeEnhancers,
    require('DevTools').instrument()
  );
}

let store = storeEnhancers(createStore)(reducer);

process.type === 'renderer' ensures that I'm not in the browser process, and !process.guestInstanceId ensures I'm not in a webView.

What I actually did in our production code was I separated BrowserStore and RendererStore and exported one based on what process I was in (since there were some other custom details).