I'd like to know how to send several arguments via ipcRenderer on an Electron app. Should I send an array of arguments or just all the arguments separated by comma?
Thanks,
I would recommend an object for parameter transfer. In consequence, you can also think about implementing a consistent API for your application:
var _myreq = {
state: 0, //0 is no error, 4 is error with message, etc.
message: "", //can include error message (if any)
data: [0,4,6] //application data for request (String, Array, Object)
};
ipc.send('mychannel-functiona', _myreq);
Docs clearly shows that you can pass any number of argument to send
.
Send a message to the main process asynchronously via channel, you can also send arbitrary arguments. Arguments will be serialized in JSON internally and hence no functions or prototype chain will be included.
From that point on you have no restrictions on how to use those arbitrary arguments. It depends on your needs, your codebase style etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With