At the first start of the application I'm writing the active user of the authentication cookie to the redux store. But when my app initially loaded the activeUser value is still null (the default value of the store in the main process). Only after a reload it is working fine.
What I have found out so far:
The main process is initialize with an empty activeUser
The preload is dispatching an action which will only be send to the main process
The main process is receiving the action and is changing the main store
The main process is sending back the action to the renderer
The renderer is not receiving the action via the ipcRenderer.on() listener
After a reload the renderer will receive the action
Solution 1 (recommended)
One solution (and the best IMO) would be not to ignore the actions within the renderers, but to ignore them instead in the forwardToRenderer function because then you don't have to forward them from the main process back to the renderer that was originally the root of that action which will also speed up the app a little bit. To achieve this, it would be necessary to add an identifier to the renderers.
At the first start of the application I'm writing the active user of the authentication cookie to the redux store. But when my app initially loaded the
activeUser
value is stillnull
(the default value of the store in the main process). Only after a reload it is working fine.What I have found out so far:
activeUser
ipcRenderer.on()
listenerSolution 1 (recommended)
One solution (and the best IMO) would be not to ignore the actions within the renderers, but to ignore them instead in the
forwardToRenderer
function because then you don't have to forward them from the main process back to the renderer that was originally the root of that action which will also speed up the app a little bit. To achieve this, it would be necessary to add an identifier to the renderers.Solution 2 (workaround)
The second solution would be to wait when the window is loaded and then send the event actions. The problem would be that this could easily lead to a slower UX and also to flickering of the ui during the first render, just in case you have exactly this problem. https://github.com/klarna/electron-redux/blob/c6f8521cbc0c29a0efd9795486b477e40834d40e/packages/electron-redux/src/middleware/forwardToRenderer.js#L20 This line could be replaced with something similar to the following one:
Desktop: