redux-electron-store
redux-electron-store copied to clipboard
Possible race condition ?
As far as I understand how this works, each renderer is responsible for generating its own state diff and send it to main.
Now an example: Here is the main store
store = {
items: {
}
}
Now let's assume that we have 2 renderers that are concurrently generating the following states: Renderer 1
store = {
items: {
item1: 'renderer1'
}
}
Renderer 2
store = {
items: {
item1: 'renderer2'
}
}
At the same time, they will send a diff to main that could look like this (jsdiff notation): Renderer 1
{ "op": "add", "path": "/items", "value": { "item1": "renderer1" } }
Renderer 2
{ "op": "add", "path": "/items", "value": { "item1": "renderer2" } }
In this case, main will successfully apply the first one it receives, but the second one will fail (because of the item1
key).
Did I misunderstood something, or could this really happen ?
Answered my own question I think. I saw your comment on #28, and the main does not receive a diff but an action, which then generates the diff
Actually my point is still valid because of what you said here