Skip to content

Communication between preload and Vue #1903

Answered by Barrosy
Barrosy asked this question in Q&A
Discussion options

You must be logged in to vote

I got the answer to my question by researching deeper into the usage of contextBridge (as cited above).

I adjusted my preload.js so that it now implements logic for retreiving dependency information:

const { ipcRenderer, contextBridge } = require("electron")

let dependencies = {}

for (const dependency of ['chrome', 'node', 'electron']) {
    dependencies[`${dependency}-version`] = process.versions[dependency]
}

//Communication between renderer process and main process:
contextBridge.exposeInMainWorld("api", {
    greet: (message) => ipcRenderer.send("greet", message),
    getVersion: () => ipcRenderer.invoke("version"),
    getDependencies: async () => { return dependencies }
})

The mo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Barrosy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant