-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] Use redux-electron-store #108
Comments
This one is quite interesting. I will give it a try next month. |
I also wanted to dispatch some actions from main process, and also to share state between multiple windows. const remote = require('electron').remote;
const store = remote.require('./app/store');
render(
<Provider store={store}>
<CounterPage/>
</Provider>,
document.getElementById('root')
); Works perfectly. Had to hook babel into main proc though. |
@domasx2 when you hook babel into the main proc, are you then able to successfully run |
Yeah, stage-0 preset was somewhy crapping out on main proc. //.babelrc
{}
//bootstrap.js
require('babel-register')({
"presets": ["es2015"],
"plugins": ["transform-object-rest-spread"],
"ignore": /(browser\/api|common\/api)/
});
require('./main');
//package.json
...
"main": "bootstrap.js"
...
//webpack.base.js
...
loaders: [{
test: /\.jsx?$/,
loader: 'babel-loader',
query: {
"presets": ["es2015", "stage-0", "react"],
"plugins": ["add-module-exports"]
},
exclude: /node_modules/
}
...
//webpack.development.js
...
config.module.loaders.forEach(function(loader) {
if (loader.loader === 'babel-loader') {
loader.query.presets.push("react-hmre");
}
});
... |
@naderhen I recommend using babel compile in production mode ( Also, in my personal project, I using |
@domasx2 running the packaged application works for you with your setup? Things build perfectly in development, but the packaged app still throws the following error: If you have a fork of this boilerplate I'd love to take a look! |
Oh yeah, I did encounter this. The problem is that package.js omits some babel files by accident. Solution was to remove this line: https://github.com/chentsulin/electron-react-boilerplate/blob/master/package.js#L25 Unfortunately my changes for this are in a private repo. I think it would be more worthwhile to "do it properly" and make a PR where package.js babelifies the source rather than include babel in the distro though. Perhaps will get around to doing it eventually... |
I had the same problem to solve. I didn't was aware of Instead of keep store state in sync between process, I send needed actions around using ipc. If you like the concept interesting, here are the modules I plan to extract on their own package. I'm using them here and here is how I setup the renderer process, here the main process. I can easily share actions between BrowserWindow instances, and between BrowserWindow and main process (I use it e.g. to change tray icon when some acions occurs.) |
I didn't like the way I basically keep the store on the main process, and a proxy store in each renderer process (that gets initialised with the main store's state). Actions fired from the renderer have a This approach has the advantage that renderers can also fire locally scoped actions (e.g. to change presentational state) without polluting the global store, but are always kept in the loop about global changes. Check hardchor/timesheets@9d2c208 for the diff. |
@hardchor: Awesome, could be a good candidate for an npm module. :) |
@davej Well, would you believe it! It only took me 2 months, but I've finally gotten around to pulling it out of my project and into npm: https://www.npmjs.com/package/electron-redux Feel free to play around, rip apart, and feedback 😄 @chentsulin My project (https://github.com/hardchor/timesheets) is based on |
I've looked through your time sheets repo and I have now implemented in a similar way using your npm module and its working great! I'm just struggling and also unsure if there is any way of having actions dispatched in the main process appear in the dev tools or any log of them whatsoever, they appear to be firing and updating state, but I have no way of tracking what actions have and haven't been sent! |
@alexemorris Let's continue this discussion in https://github.com/hardchor/electron-redux/issues/new |
I think we should add a guide on how to add integration with electron-redux. Let's move this discussion to #968 |
We can use redux-electron-store, in this way, we can let main process dispatch actions to other BrowserWindow.
I have such a demand, but this boilerplate will become too complicated? I would like to know everyone views.
The text was updated successfully, but these errors were encountered: