#How to pass variables from an ipcMain.on function to an outside variable?

13 messages · Page 1 of 1 (latest)

blazing imp
#

how familiar you with js?

twilit oracle
#

beginner

blazing imp
#

beginner like i dont know or?

#

or you dont know js at all

twilit oracle
#

I don't know what my level is, I'm just a hobbyist.

blazing imp
#

do you know what scope is?

#

or eventloop?

#

how you supposed to use variables outside of other function?

#

why you didnt use global variables you assign values to?

twilit oracle
#

ipcMain.on("ComPortBaundrateValues" happens after creating the object const port = new SerialPort(config), I think the problem is more related to creating this object dynamically through ipcMain.on("ComPortBaundrateValues", but if I do this this object will not be visible to other functions that use it...

twilit oracle
#

How is it possible to make the object const port = new SerialPort(config) global?

blazing imp
#

declare variable in other scope

twilit oracle
#

agora está funcionando 100%