-
Notifications
You must be signed in to change notification settings - Fork 94
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
Restarting Redux environment without triggering preventDoubleInitialization? #293
Comments
Turns out this is still very manageable although the solution forces us into using inline To facilitate restarting the Redux environment: configurestore.js if (scope === 'renderer') {
enhancers.push(require('electron-redux').rendererStateSyncEnhancer());
} else if (scope === 'main') {
enhancers.push(require('electron-redux').mainStateSyncEnhancer());
} main.js // destroy all your windows and then...
ipcMain.removeHandler('electron-redux.INIT_STATE_ASYNC');
ipcMain.removeAllListeners('electron-redux.INIT_STATE');
ipcMain.removeAllListeners('electron-redux.ACTION'); |
@slapbox I think I saw a notification yesterday at night about a comment, but I don't see that comment here anymore 🤔 In terms of supporting this - I don't see any reason why we could not extend API to support this in the future - but we would need to understand how we plan to solve that and so on. If you are interested and have some ideas in mind, let me know and we could brainstorm it together |
Indeed, I commented but I found the issue. But I'm not really sure why removing some code I'd committed fixed it. Would there be any downside to making The solution we have right now involves using inline requires which are a bit more difficult to reason about I feel. |
We just upgraded to the
2.0.0-alpha.9
and the new setup looks amazingly simple!I've not gotten things working quite yet, and maybe won't be able to quite yet, but one thing I noticed is
preventDoubleInitialization
https://github.com/klarna/electron-redux/blob/alpha/src/utils/misc.ts#L5
With electron-redux@1.x we had built in a custom functionality to restart the redux environment to avoid having to restart our entire project.
The core of our solution was just to use something like below to unregister all channels before we re-create our app's windows from scratch:
Is there a way to achieve this with the new architecture? If not, might I suggest that
previouslyInitialized
(https://github.com/klarna/electron-redux/blob/alpha/src/utils/misc.ts#L5) be made into a global instead so users can manually reset it if needed?The text was updated successfully, but these errors were encountered: