samiskin / redux-electron-store

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

Duplicate objects becoming `null` when sent over IPC #10

Closed davej closed 8 years ago

davej commented 8 years ago

I was getting null values in my objects when sent over IPC, for example the message got sent as:

{
   "type":"ADD_SITES",
   "payload":[
      {
         "name":"Stark Industries",
         "id":"1234"
      },
      {
         "name":"CHAOM",
         "id":"5678"
      },
      {
         "name":"Oceanic Airlines",
         "id":"1111"
      },
      {
         "name":"Marketing Site",
         "id":"9999"
      }
   ],
   "source":"browser",
   "data":{
      "updated":{
         "sites":[
            {
               "name":"Stark Industries",
               "id":"1234"
            },
            {
               "name":"CHAOM",
               "id":"5678"
            },
            {
               "name":"Oceanic Airlines",
               "id":"1111"
            },
            {
               "name":"Marketing Site",
               "id":"9999"
            }
         ]
      },
      "deleted":{}
   }
}

But was received as:

{
   "type":"ADD_SITES",
   "payload":[
      {
         "name":"Stark Industries",
         "id":"1234"
      },
      {
         "name":"CHAOM",
         "id":"5678"
      },
      {
         "name":"Oceanic Airlines",
         "id":"1111"
      },
      {
         "name":"Marketing Site",
         "id":"9999"
      }
   ],
   "source":"browser",
   "data":{
      "updated":{
         "sites":[ null, null, null, null ]
      },
      "deleted":{}
   }
}

This seems to be related to https://github.com/atom/electron/issues/874. It can be easily fixed by serializing the action to JSON. I'll do a PR now.