This package has been deprecated

Author message:

use electron-utils instead

electron-lib

1.0.3 • Public • Published

Electron-Lib

npm version

Some helper functions to accelerate your Electron development work

Register App Protocol

Why you need to use file protocol or local file path to locate your files? With the follow code, you can use app://views/welcome/index.html to locate file://path/to/app/views/welcome/index.html

In app.js

const elib = require('electron-lib')
elib.registerAppProtocol()

Window Creation and Management

const elib = require('electron-lib')
const options = {width: 600, height: 400}
elib.windows.createOrActivate('welcome', 'app://views/welcome/index.html', options)
// some time later...
elib.windows.activate('welcome')

IPC Between Browser Window and Main Process

The default ipc methods are too complex. We need just one line

// In main process
const elib = require('electron-lib')
elib.ipc.registerIPCHandler('newwin', (url, name) => {
  elib.windows.createOrActivate(name, url, {width: 640, height: 480})
})
 
// In renderer process (browser window)
ipc.handleIPCRequest('newwin', ['https://github.com/', 'github'])

Readme

Keywords

Package Sidebar

Install

npm i electron-lib

Weekly Downloads

0

Version

1.0.3

License

Apache-2.0

Unpacked Size

16.3 kB

Total Files

7

Last publish

Collaborators

  • stanleyxu2005