New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

electron-path-ipc

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-path-ipc

Express style path for Electron IPC

latest
Source
npmnpm
Version
0.0.10
Version published
Maintainers
1
Created
Source

electron-path-ipc

npm Code Style: Google Code: TypeScript Made By: StudiMax

Installation

# with npm
$ npm install electron-path-ipc
# with yarn
$ yarn add electron-path-ipc

Usage

By default, the main process send a request to all renderer process.

// main process
import {ipcMain} from 'electron-path-ipc';
ipcMain.on(':identifier/action', (headers,...args)=>{
    console.log(headers.params); // {identifier: 'my-identifier'}
    console.log(args); // ['hello world']
})

// renderer process
import {ipcRenderer} from 'electron-path-ipc';
ipcRenderer.send('my-identifier/action', 'hello world');

You can use invoke/handle in both main and renderer process.

// main process
import {ipcMain} from 'electron-path-ipc';

ipcMain.handle(':identifier/action', (headers, arg) => {
    console.log(headers.params); // { identifier: 'my-identifier' }
    return `${arg} world !`
})

// renderer process
import {ipcRenderer} from 'electron-path-ipc';

ipcRenderer.invoke('my-identifier/action', 'hello')
    .then(console.log) // 'hello world'

You can use prefix to simplify yours requests

// main process
const prefixedIpc = ipcMain.prefix('test/').prefix('test2/');

prefixedIpc.handle(':identifier/action', (headers, arg) => {
    return `${arg} world !`
})

// is the equivalent of
ipcMain.handle('test/test2/:identifier/action', (headers, arg) => {
    return `${arg} world !`
})

Keywords

electron

FAQs

Package last updated on 19 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts