electron-ipc
Advanced tools
Comparing version 0.1.0 to 0.2.0
17
index.js
@@ -11,2 +11,3 @@ 'use strict' | ||
let MESSAGES = {} | ||
let WINDOWS = [] | ||
@@ -17,3 +18,7 @@ function sendIPC (...args) { | ||
MESSAGES[id] = {resolve, reject} | ||
TARGET.send('handoff.request', id, ...args) | ||
if (IS_RENDERER) { | ||
TARGET.send('handoff.request', id, ...args) | ||
} else { | ||
WINDOWS.forEach(win => win.webContents.send('handoff.request', id, ...args)) | ||
} | ||
}) | ||
@@ -44,2 +49,12 @@ } | ||
addWindow (win) { | ||
WINDOWS.push(win) | ||
}, | ||
removeWindow (win) { | ||
let idx = WINDOWS.indexOf(win) | ||
if (!~idx) return | ||
WINDOWS.splice(idx, 1) | ||
}, | ||
publish (...args) { | ||
@@ -46,0 +61,0 @@ return sendIPC(...args) |
{ | ||
"name": "electron-ipc", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "IPC for Electron using promises", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
5272
65