I am trying to build a simple Electron app using Julia as my back-end language and HTML/CSS/Javascript as front-end by means of the Electron.jl package. Essentially, I have written a CVM structure on the back-end to handle data from my SQLite database, which I want to communicate to the front-end in order to display (sufficient for now). I am aware that you can run Javascript functions in Julia, but cannot figure out how to request the data on the back-end from Javascript. As you may notice, I am not the most advanced user of these languages (I have only self-taught knowledge of front-end development and some shallow work experience), so please excuse me if I asked a preposterous question.
I have tried to add
win.webContents.executeJavaScript("const {ipcRenderer} = require('electron'); function callJulia(name, ...args) { ipcRenderer.send('ipc-message', name, ...args); }; global['callJulia'] = callJulia;undefined")
to the existing snippets in Electron.jl:
win.webContents.on("did-finish-load", function() {
win.webContents.executeJavaScript("const {ipcRenderer} = require('electron'); function sendMessageToJulia(message) { ipcRenderer.send('msg-for-julia-process', message); }; global['sendMessageToJulia'] = sendMessageToJulia;undefined")
})
However, the function was not recognized in Javascript when I tried to use it. I must say this was mainly the suggestion of ChatGPT, whose ‘expertise’ in this niche is rather unhelpful.
Thank you in advance!
Niels van den Heuvel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.