#Display the variable from .js to .html in electron
254 messages · Page 1 of 1 (latest)
I don't know how to do it
idea
If you supposed to use electron you need nodejs/web knowledge
Use the ipcMain and ipcRenderer modules to communicate between Electron processes
where is preload file?
this is the issue
What I need to add?
have you seen example from link above?
yeah, but I don't understand it
what exactly?
example different from what I nedd
its example
added this, still same error
have you change your code after that change?
Use the ipcMain and ipcRenderer modules to communicate between Electron processes
this is button click event
to check renderer every second
how do you listen before?
Im not
noob.
how you supposed to use electron then?
I think it's another "spoon story", as you would put it
why the error gone then?
:/
I did it, but with
contextIsolation: false,
}```
I deleted const { ipcRenderer } = require('electron'); from trades.js file
it work but with disabled security feature
in main.js
trades.js
how to do it correctly with enabled security feature ?
what I shoud add to preload ?
by using preload file
what I shoud add to preload ?
have you read docs anout preload file?
Electron inherits its multi-process architecture from Chromium, which makes the framework architecturally very similar to a modern web browser. This guide will expand on the concepts applied in the tutorial.
this one?
yeah, but I don't understand what I should send from preload file to the main file
ohh
with preload you can extends renderer
like this one
Use the ipcMain and ipcRenderer modules to communicate between Electron processes
what didnt work?
for what?
to get variable from preload
no
so how I need to move api from trades.js to preload ?
you cant move it
if you move dependency into preload
you should work with them in preload
how I need to do it?
do you know what those errors means?
no
do you know what reference is?
yes
this ?
there are many things on this image
your errors means that varaibles ipcRenderer and require is not defined
becase require is not usable in browser/renderer code by default
and you cant use require at all
if you cant use require electron you cant require ipcRenderer and use it
thats why you have preload file
where you have require
and can use it
with ipcRenderer
and you have contextBridge to extends renderer code with some api
so it mean my preload file is not correct ?
you have old code with ipcRenderer and require in index.html and trades.js files
I cant use ipcRenderer.send in trades.js ?
no
can't or can ?
but firstly I need to edit my preload file correctly
I need ipcRenderer.send in preload ?
and sent variable from trades.js to preload via preload apis ?
You already have ipcRenderer.send in preload
is it correct ?
okay, but what I need to do in html ?
Same thing?
electronApi.get ?
don't use require in the renderer
i dont
What data is?
You do, or else you wouldn't have this error
topValues I think
what I should do with this ?
these are the only require I use in trades.js
Remove it
I can't, then code wouldn't work
Its doesn't work because if require as well
If you wanted to work with it move your code into preload
but then preload file would be so big
can I somehow move it to preload and then use it in trades from preload ?
you can require trades in preload
how?
with require()
what u mean ?
do you know what require() is?
what import is?
get something from somewhere
whole trades.js file ?
whole file
but I will still use require in trades.js
added const trades = require('./trades.js'); to preload, but still have errors
One key security feature in Chromium is that processes can be executed within a sandbox. The sandbox limits the harm that malicious code can cause by limiting access to most system resources — sandboxed processes can only freely use CPU cycles and memory. In order to perform operations requiring additional privilege, sandboxed processes use dedi...
I think I don't have data because of this
no
okay, but how to fix it?
also use ipcRenderer in html ?
no
what use instead ?
have you followed IPC tutorial?
used for what?
to display variable in html
do you have variable to display?
topValues from trades
before I used ipcRender to display data from main.js
you used ipcRenderer to get it
okay, how to get it without iprRenderer ?
for example ?
I have this
do you know what this code do?
send data
from where?
from trades.js
and send data to?
idk
display topValues from trades.js in .html
how do you get topValues in trades?
from binance api and webSocket
show me the code
why do you add script into html file?
now 2 errors
cant I just use only getElementById somehow ?
you can
I tried it before but it didn't work
bruh
it work
oh
it didn't work because of preload
It needed to require trades.js
all these days I only had to add 1 line of code 
@lapis ice Thank you
wait, why this happened?
becase it cant load source map
why not?
becase it doesnt exists
what doesnt exists?
source maps
so I can ignore it ?
and why not only 1 line of code
I explaned all in the title..
do you understand what you did?