L
L
lem_prod2016-03-04 11:26:59
JavaScript
lem_prod, 2016-03-04 11:26:59

What are variable scopes in Electron?

1. You can transfer variables from main.js to index.html ... in general, how to get access to the main js file from loaded ones, for example, pass an event.
2. Is there some kind of variable area in electron where variables will be saved during reboot?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2017-03-14
@sergiks

You can get a global variable in the renderer process like this:
In the main process (main.js): global.something = value;
In the renderer process (index.html):

const remote = require('electron').remote;
var something = remote.getGlobal('something');

( from here )

Y
Yuri, 2016-03-04
@riky

practically did not work with electron, but studied it.
they have separate scopes, so for data transfer it is necessary to use special designed events.
see details
https://github.com/atom/electron/blob/master/docs/...
https://github.com/atom/electron/blob/master/docs/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question