electron-process

0.2.0 • Public • Published

electron-process

Send blocking operations to a background process. Example application available here.

Installation

npm install --save electron-process

Usage

electron-process uses a hidden BrowserWindow to do all the blocking operations that your heart desires. Create the background process in the main electron process, register modules you wish to run in the background, then call those functions within the BrowserWindows that you consider the foreground.

Main

const main = require('electron-process').main;
 
app.on('ready', function() {
  const backgroundURL = 'file://' + __dirname + '/background.html';
  const backgroundProcessHandler = main.createBackgroundProcess(backgroundURL, true);
  mainWindow = new BrowserWindow({width: 1280, height: 600});
  backgroundProcessHandler.addWindow(mainWindow);
  mainWindow.loadURL('file://' + __dirname + '/foreground.html');
});

Foreground

const foreground = require('electron-process').foreground;
const someModule = foreground.getModule(require('./someModule'));
someModule.doStuff()
  .then((result) => console.log(result));

Background

const background = require('electron-process').background;
background.registerModule(require('./someModule'));

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    21
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    21
  • 0.1.3
    1
  • 0.1.2
    1
  • 0.1.1
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i electron-process

Weekly Downloads

25

Version

0.2.0

License

ISC

Last publish

Collaborators

  • smith-kyle