redux-electron-store
redux-electron-store copied to clipboard
Forward action in main to renderer
@samiskin
Hi!
I am experiencing the following issue:
Renderer fires an action that is forwarded to main. As far as I understand with the latest lib this action will not be dispatched in the renderer, but forwarded directly to main - is this correct?
After main runs the action through the reducer and creates the patch the renderer is not being notified and hence state not being updated. I have looked into the code and after uncommenting the line below things seem to work.
clients[webContentsId].clientId === context.flags.senderClientId) continue;
@ https://github.com/samiskin/redux-electron-store/blob/master/src/main-enhancer.js#L66 (if ()
Is it only on my end I have this issue?
@arieldf by "the latest lib" do you mean the master version of this repo?
@arieldf So right now master
has the renderer
that dispatches the action running the action through its reducer, then the diff from that update gets sent to main
. main
then applies the update to itself and forwards that update to the other renderer
s for them to apply to themselves.
The reason it isn't ran in master
only is that lets say your renderer has its own state properties that it doesn't want to have in the main
store and doesn't want to be synchronized. If I run the action only in the main process, and the main process doesn't care about that particular action, the renderer is never notified. The assumption that I currently go with is that the renderer's reducer is a superset of the main's reducer.
Assuming you're using the master
version of this repo (on npm under beta
) I wasn't able to reproduce the issue. I just tried running an action from the reducer, and the reducer did update along with main.