var eventName = 'dactElectron';

function syncElectrons(extend) {
  return extend;
}

export default function dactElectron(ipc) {
  for (var _len = arguments.length, windows = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    windows[_key - 1] = arguments[_key];
  }

  return function (data) {
    ipc.on(eventName, function (event, extend) {
      data.emit(syncElectrons, extend);
    });

    return function (next) {
      return function (extend, meta) {
        if (meta !== syncElectrons.name) {
          if (windows.length) {
            windows.forEach(function (win) {
              win.webContents.send(eventName, extend);
            });
          } else {
            ipc.send(eventName, extend);
          }
        }

        return next(extend);
      };
    };
  };
}