Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ipcrenderer preload.js

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

// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld(
    "api", {
        //send: (channel, data) => {
        request: (channel, data) => {
            // whitelist channels
            let validChannels = ["toMain"];
            if (validChannels.includes(channel)) {
                ipcRenderer.send(channel, data);
            }
        },
        //receive: (channel, func) => {
        response: (channel, func) => {
            let validChannels = ["fromMain"];
            if (validChannels.includes(channel)) {
                // Deliberately strip event as it includes `sender` 
                ipcRenderer.on(channel, (event, ...args) => func(...args));
            }
        }
    }
);
Comment

PREVIOUS NEXT
Code Example
Javascript :: searchbar to bottom table datatable 
Javascript :: valueof js 
Javascript :: js insert after element 
Javascript :: html js display pdf file 
Javascript :: why does javascript let you write a function without the parentheses 
Javascript :: javascript match against array 
Javascript :: Delete a Cookie with JavaScript 
Javascript :: order by type 
Javascript :: picture in picture remove from videojs 
Javascript :: javascript closest data attribute 
Javascript :: × Error: Invariant failed: You should not use <Switch outside a <Router 
Javascript :: javascript code to test if screen is idle 
Javascript :: es6 get first and last element of array 
Javascript :: javscript randomly generate 89digit number 
Javascript :: how to filter an array of strings to see which letters match javascript 
Javascript :: extend current date with 30 days in jquery datepicker 
Javascript :: react i18n with parameeter 
Javascript :: schema mongoose 
Javascript :: three ways of writing a function in javascript 
Javascript :: delegate click in jquery 
Javascript :: js replace text link with anchor tags 
Javascript :: show ad on facebook game 
Javascript :: get data firebase 
Javascript :: vue not loading env variables 
Javascript :: leaflet js mobile popup not opening 
Javascript :: jQuery download video from URL 
Javascript :: javascript reload section 
Javascript :: select div with clas 
Javascript :: create slug in express 
Javascript :: how to get the value of AutoCompelet Component in MUI 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =