samiskin / redux-electron-store

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

replaceReducer breaks synchronisation? #48

Open TanninOne opened 7 years ago

TanninOne commented 7 years ago

I'm encountering an issue and am not sure if I'm doing something wrong or if this is a bug.

What happens is: My app loads in two phases, the store is originally initialized with a limited set of reducers and then I call replaceReducers (in both main and renderer process) to load the rest. After this, once I dispatch an action in the main process, future actions in the renderer process aren't forwarded to the main process any more.

I've debugged this and followed the trail to "mainProcessUpdateFlag" which gets set to true when the renderer receives (to prevent the same action to be sent back to main?) an ipc from main and never gets reset. It looks like the flag gets reset in "parsedReducer" which, as far as I understand it, is a wrapper around the reducers initially passed with createStore? So when I call replaceReducer I replace this wrapped reducer with a vanilla one and the code that resets the flag no longer gets called. However, from the documentation about hot-reloading it appears that replaceReducer is supposed to be supported?

Any help would be appreciated.