Promise from main process to renderer process with remote object



In my electron app, I have a simple node module, which is storing a simple object petStore. This module exposes 2 methods:

  • getItems which return a Promise resolving with petStore
  • addItem(key, value)which add a new entry to thepetStore` object

In my BrowserWindow, I am requiring this module, through the remote object, like this:
var store = require('electron').remote.require('./promise-store.js')

Then, on certain actions I am calling addItem, which is properly updating the petStore object in the main process.

But then, when I am calling getItems in my BrowserWindow, the promise is still resolving with the initial object values, like if nothing was added in the module.

Could someone explain me what’s the issue here ?

Here is the code, if my explanation lacks of clarity.


Reading the doc, I found out that this has nothing to do with promise, but relates to how eletron remote passes object to the renderer process. I was just no reading the up-to-date documentation.

Answer is here, in the first Note statement:

Only enumerable properties which are present when the remote object is first referenced are accessible via remote.