How to use the electron.ipcMain.on function in electron

To help you get started, we’ve selected a few electron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github urbanogardun / monte-note / src / main.ts View on Github external
// Sort them by date created
    // Get last item
    
  });

  ipcMain.on(GET_TRASH, (event: any, args: any) => {
    dbMessager.getFromSettings('notebooksLocation')
    .then((location: string) => {
      NotebookManager.getTrash(location)
      .then((data: object) => {
        event.sender.send(GET_TRASH, data);
      });
    });
  });

  ipcMain.on(GET_NOTE_FROM_TRASH, (event: any, data: any) => {
    let note = data.note;
    let notebook = data.notebook;

    dbMessager.getFromSettings('notebooksLocation')
    .then((location: string) => {
      let absolutePathToNote = path.join(location, TRASHCAN, notebook, note, 'index.html');
      NotebookManager.getNoteData(absolutePathToNote)
      .then((noteData: string) => {
        let noteInfo = {
          note: note,
          notebook: notebook,
          data: noteData
        };
        event.sender.send(GET_NOTE_FROM_TRASH, noteInfo);
      });
    });
github oliverschwendener / ueli / src / js / main.js View on Github external
hideWindow()
    })

    ipcMain.on('hide-main-window', (event, arg) => {
      hideWindow()
    })

    ipcMain.on('close-main-window', quitApp)

    ipcMain.on('reload-window', () => {
      setWindowOptions()
      setGlobalShortcuts()
      mainWindow.reload()
    })

    ipcMain.on('get-info', () => {
      getInfo()
    })

    ipcMain.on('check-for-update', () => {
      autoUpdater.checkForUpdates()
    })

    ipcMain.on('install-update', () => {
      autoUpdater.downloadUpdate()
    })

    setGlobalShortcuts()
    setWindowOptions()
    setZoomFactor()

    autoUpdater.autoDownload = false
github 2youyou2 / quick-preview / main.js View on Github external
load () {
    Editor.Metrics.trackEvent({
      category: 'Packages',
      label: 'quick-preview',
      action: 'Panel Load'
    }, null);

    ipcMain.on('generate-src-file', onGenerateSrcFile);
    ipcMain.on('app:reload-on-device', onAppReloadOnDevice);
  },
github nebrius / contact-scheduler / main / src / index.ts View on Github external
createCalendar(parsedArgs.calendar, finalizeCalendarOperation);
  } else {
    updateCalendar(parsedArgs.calendar, finalizeCalendarOperation);
  }
});

ipcMain.on(MessageTypes.RequestDeleteCalendar, (event: Event, arg: string) => {
  const parsedArgs: IDeleteCalendarMessage = JSON.parse(arg);
  deleteCalendar(parsedArgs.calendar, finalizeCalendarOperation);
});

ipcMain.on(MessageTypes.CloseNotification, (event: Event, arg: string) => {
  closeNotification();
});

ipcMain.on(MessageTypes.Respond, (event: Event, arg: string) => {
  respond((err) => {
    if (err) {
      error(`Could not respond to contact: ${err}`);
    } else {
      log('Respond to contact');
      updateQueueInClient();
    }
    closeNotification();
  });
});

ipcMain.on(MessageTypes.PushToBack, (event: Event, arg: string) => {
  pushToBack((err) => {
    if (err) {
      error(`Could not push contact to the back of the queue: ${err}`);
    } else {
github johansatge / vuplicity / app / assets / js / controllers / main.js View on Github external
var _handleViewEvents = function()
    {
        ipc.on('control-panel-ready', function()
        {
            glob.sync(configPath.replace('%s', '*'), {}).map(function(path, index)
            {
                _registerBackup(index, path, false);
            });
        });
        ipc.on('create-backup', function()
        {
            var id = new Date().getTime();
            _registerBackup(id, configPath.replace('%s', id), true);
        });
        ipc.on('cancel-process', function(evt, id)
        {
            backups[id].cancelProcess();
        });
        ipc.on('select-backup-path', function(evt, id)
        {
            ControlPanelDialogs.selectBackupPath(function(path)
            {
                controlPanelWindow.send('set-backup-path', path, id);
            });
        });
        ipc.on('refresh-status', function(evt, id)
        {
            _setUI.apply(this, [id, 'processing', 'Refreshing status...']);
            backups[id].refreshBackupStatus();
        });
        ipc.on('refresh-file-tree', function(evt, id)
github fluidtrends / carmel / studio / src / Session.js View on Github external
listen(key, cb) {
        ipcMain.on(key, (event, data) => {
            cb && cb(data)
        })
    }
github geeeeeeeeek / electronic-wechat / src / main.js View on Github external
ipcMain.on('update', (event, message) => {
      let updateHandler = new UpdateHandler();
      updateHandler.checkForUpdate(`v${app.getVersion()}`, false);
    });

    ipcMain.on('open-settings-window', (event, message) => {
      if (this.settingsWindow) {
        this.settingsWindow.show();
      } else {
        this.createSettingsWindow();
        this.settingsWindow.show();
      }
    });

    ipcMain.on('close-settings-window', (event, messgae) => {
      this.settingsWindow.close();
      this.settingsWindow = null;
    })
  };
github jaruba / PowderPlayer / src / browser.js View on Github external
ipcMain.on('app:get:fullscreen', (event) => {
        event.returnValue = mainWindow.isFullScreen();
    });

    ipcMain.on('app:get:maximized', (event) => {
        event.returnValue = mainWindow.isMaximized();
    });

    ipcMain.on('app:fullscreen', (event, state) => mainWindow.setFullScreen(state));

    ipcMain.on('app:maximize', (event, state) => {
        state ? mainWindow.maximize() : mainWindow.unmaximize();
    });

    ipcMain.on('app:alwaysOnTop', (event, state) => mainWindow.setAlwaysOnTop(state));

    ipcMain.on('app:setThumbarButtons', (event, buttons) => mainWindow.setThumbarButtons(buttons));

    ipcMain.on('app:bitchForAttention', (event, state = true) => {
        if (!mainWindow.isFocused())
            mainWindow.flashFrame(state);
    });

    ipcMain.on('app:powerSaveBlocker', (event, state) => {
        let enablePowerBlock = () => {
            powerSaveBlockerState = powerSaveBlocker.start('prevent-display-sleep');
        };
        let disablePowerBlock = () => {
            if (powerSaveBlockerState)
                powerSaveBlocker.stop(powerSaveBlockerState);
        };
github cheshire137 / competiwatch-desktop / src / electron-database.js View on Github external
return databases.seasons;
  }
  if (name === "settings") {
    if (!databases.settings) {
      loadSettingsDatabase();
    }
    return databases.settings;
  }
};

ipcMain.on("get-db-path", (event, replyTo, dbName) => {
  const dbPath = getDatabaseFilename(dbName);
  event.sender.send(replyTo, dbPath);
});

ipcMain.on("find-one", (event, replyTo, dbName, conditions) => {
  const db = databaseFor(dbName);
  if (!db) {
    log.error(dbName, "database not loaded for find-one");
    event.sender.send(replyTo, "database not loaded");
    return;
  }

  db.findOne(conditions, (err, data) => {
    if (err) {
      log.error("find-one error", err);
    }
    event.sender.send(replyTo, err, data);
  });
});

ipcMain.on("find-all", (event, replyTo, dbName, sort, conditions) => {