3
votes

The main process opens a connection to a service, to which a renderer requires access.

Is this possible?

I've tried declaring global.thing and exports.thing, and having the renderer require('electron').remote.thing — where thing is a function or scalar — but no luck.

1

1 Answers

6
votes

You can do it in more ways:

1) Communicate between process with ipc and ask data with ipcRenderer.sendSync function, that asks to main process and wait for a return value. https://github.com/electron/electron/blob/master/docs/api/ipc-renderer.md

2) use exports in the right way, so:

in the main process:

exports.functionName = functionName;

in the renderer:

var functionName = remote.require('./main').functionName;