electron-event-flux
Advanced tools
Comparing version 0.7.6 to 0.7.7
@@ -13,2 +13,4 @@ 'use strict'; | ||
var findIndex = require('lodash/findIndex'); | ||
module.exports = function () { | ||
@@ -20,3 +22,3 @@ function ElectronMainClient(callbacks) { | ||
this.clients = {}; | ||
this.clientIds = []; | ||
this.clientInfos = []; | ||
window.isMainClient = true; | ||
@@ -43,6 +45,8 @@ | ||
// Child window has closed | ||
var index = _this.clientIds.indexOf(clientId); | ||
if (index !== -1) _this.clientIds.splice(index, 1); | ||
var index = findIndex(_this.clientInfos, function (item) { | ||
return item.clientId === clientId; | ||
}); | ||
if (index !== -1) _this.clientInfos.splice(index, 1); | ||
_this.clients[clientId] = null; | ||
_this.callbacks.deleteWin(clientId); | ||
callbacks.deleteWin(clientId); | ||
} else if (action === renderRegisterName) { | ||
@@ -54,3 +58,3 @@ var filter = data.filter, | ||
_this.clients[_clientId] = window; | ||
_this.clientIds.push(_clientId); | ||
_this.clientInfos.push({ clientId: _clientId, filter: filter }); | ||
window.postMessage({ | ||
@@ -66,7 +70,9 @@ action: mainInitName, | ||
value: function getForwardClients() { | ||
return this.clientIds; | ||
return this.clientInfos; | ||
} | ||
}, { | ||
key: 'sendToRenderer', | ||
value: function sendToRenderer(clientId, payload) { | ||
value: function sendToRenderer(_ref2, payload) { | ||
var clientId = _ref2.clientId; | ||
var window = this.clients[clientId]; | ||
@@ -73,0 +79,0 @@ window && window.postMessage({ action: mainDispatchName, data: payload }, '*'); |
@@ -110,4 +110,2 @@ 'use strict'; | ||
var clientInfo = mainClient.getForwardClients(); | ||
var util = require('util'); | ||
console.log('all payload:', util.inspect(payload, { showHidden: false, depth: null })); | ||
@@ -114,0 +112,0 @@ clientInfo.forEach(function (client) { |
{ | ||
"name": "electron-event-flux", | ||
"version": "0.7.6", | ||
"version": "0.7.7", | ||
"description": "Redux store which synchronizes between instances in multiple process", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
const { renderRegisterName, renderDispatchName, mainDispatchName, mainInitName } = require('./constants'); | ||
const findIndex = require('lodash/findIndex'); | ||
@@ -7,3 +8,3 @@ module.exports = class ElectronMainClient { | ||
this.clients = {}; | ||
this.clientIds = []; | ||
this.clientInfos = []; | ||
window.isMainClient = true; | ||
@@ -21,6 +22,6 @@ | ||
} else if (action === 'close') { // Child window has closed | ||
let index = this.clientIds.indexOf(clientId); | ||
if (index !== -1) this.clientIds.splice(index, 1); | ||
let index = findIndex(this.clientInfos, (item) => item.clientId === clientId); | ||
if (index !== -1) this.clientInfos.splice(index, 1); | ||
this.clients[clientId] = null; | ||
this.callbacks.deleteWin(clientId); | ||
callbacks.deleteWin(clientId); | ||
} else if (action === renderRegisterName) { | ||
@@ -30,3 +31,3 @@ let { filter, clientId } = data; | ||
this.clients[clientId] = window; | ||
this.clientIds.push(clientId); | ||
this.clientInfos.push({ clientId, filter }); | ||
window.postMessage({ | ||
@@ -41,6 +42,6 @@ action: mainInitName, | ||
getForwardClients() { | ||
return this.clientIds; | ||
return this.clientInfos; | ||
} | ||
sendToRenderer(clientId, payload) { | ||
sendToRenderer({ clientId }, payload) { | ||
let window = this.clients[clientId]; | ||
@@ -47,0 +48,0 @@ window && window.postMessage({ action: mainDispatchName, data: payload }, '*'); |
@@ -54,5 +54,3 @@ import AppStore from 'event-flux/lib/AppStore'; | ||
let clientInfo = mainClient.getForwardClients(); | ||
const util = require('util') | ||
console.log('all payload:', util.inspect(payload, {showHidden: false, depth: null})) | ||
clientInfo.forEach(client => { | ||
@@ -59,0 +57,0 @@ let { filter: shape, clientId } = client; |
131739
2851