Skip to content

Commit

Permalink
Rename invoke method for consistency, add package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ylieder committed Sep 30, 2020
1 parent 35c6b09 commit 196d433
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"no-trailing-punctuation": false
}
18 changes: 0 additions & 18 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ app.whenReady().then(() => {
const windowB = createWindow('Window B');
ipcMain.registerBrowserWindow('window-b', windowB);
windowB.loadFile('index.html');

// Promise.all([promiseA, promiseB, promiseC]).then(() => {
// // All three browser windows are registered for IPC communication at this point

// ipcMain.send('window-a', 'test-send-from-main', 'Send a message from main');
// ipcMain.invoke('window-b', 'test-invoke-from-main', 'Square this number', 5)
// .then((result) => {
// console.log(`test-main-invoke: result=${result}`);
// });
// ipcMain.handle('window-c', 'test-renderer-invoke', (msg, n) => {
// console.log(`test-renderer-invoke: msg=${msg}, n=${n}`);
// return n + 5;
// });
// ipcMain.on('window-c', 'test-renderer-invoke', (msg, n) => {
// console.log(`test-renderer-invoke: msg=${msg}, n=${n}`);
// return n + 5;
// });
// });
});

app.on('window-all-closed', () => {
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
"eslint": "^7.10.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.21.2"
}
},
"name": "electron-postman",
"version": "0.1.0",
"description": "Easy Electron IPC with focus on window-to-window communication and disabled node integration in renderers",
"main": "index.js",
"repository": "[email protected]:ylieder/electron-postman.git",
"author": "Yannic Lieder",
"license": "MIT"
}
4 changes: 2 additions & 2 deletions src/ipcMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function once(windowName, channel, callback) {
}
}

function invoke(windowName, channel, ...args) {
function invokeTo(windowName, channel, ...args) {
const token = getToken();
return new Promise((resolve) => {
ipcMain.once(prefixed(windowName, channel, token), (event, result) => {
Expand Down Expand Up @@ -116,7 +116,7 @@ module.exports = {
sendTo,
on,
once,
invoke,
invokeTo,
handle,
handleOnce,
removeAllListeners,
Expand Down

0 comments on commit 196d433

Please sign in to comment.