electron-re
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "electron-re", | ||
"version": "1.0.0", | ||
"description": "", | ||
"version": "1.0.1", | ||
"description": "electron sugar utils", | ||
"main": "./lib/index", | ||
@@ -15,2 +15,7 @@ "scripts": { | ||
"license": "ISC", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/NoJsJa/electron-re" | ||
}, | ||
"homepage": "https://github.com/NoJsJa/electron-re#readme", | ||
"devDependencies": { | ||
@@ -17,0 +22,0 @@ "babel-preset-es2015": "^6.24.1", |
### electron-re | ||
--------------- | ||
Using `electron-re` to generate service process and send data from main process to service, from render process to service, and service to service. | ||
Using `electron-re` to generate some service processs and communicate between `main process`,`render process`,`service`. In some `Best Practices` of electron tutorials, it's used to | ||
#### Instruction | ||
The `service` process is a customized render process that works in the background, receiving `path`, `options` as arguments: | ||
#### I ) Instruction | ||
The `service` process is a customized render process that works in the background, receiving `path`, `options` as arguments: | ||
* path -- the absolute path to a js file | ||
@@ -12,9 +14,11 @@ * options -- the same as `new BrowserWindow()` options | ||
In order to send data from main or other process to a service you need use `MesssageChannel`, such as: `MessageChannel.send('service-name', 'channel', 'params')` | ||
#### Usage | ||
1. service | ||
#### II ) Usage | ||
##### 1. Service | ||
The service is a customized `BrowserWindow` instance, it has only method `connected()` which return a resolved `Promise` when service is ready, suggest to put some business-related code into a service. | ||
```js | ||
/* main.js */ | ||
/* --- main.js --- */ | ||
@@ -36,3 +40,3 @@ const { BrowserService } = require('electron-re'); | ||
```js | ||
/* app.service.js */ | ||
/* --- app.service.js --- */ | ||
@@ -47,7 +51,7 @@ const { ipcRenderer } = require('electron'); | ||
2. MessageChannel | ||
##### 2. MessageChannel | ||
A messaging tool expanding some method from electron build-in ipc: | ||
This is a messaging tool expanding some method from electron build-in ipc: | ||
```js | ||
/* main */ | ||
/* --- main --- */ | ||
@@ -57,4 +61,4 @@ const { BrowserService, MessageChannel } = require('electron-re'); | ||
// after app is ready in main process | ||
app.whenReady().then(() => { | ||
// after app is ready in main process | ||
const myService = new BrowserService('app', 'path/to/app.service.js'); | ||
@@ -86,5 +90,5 @@ myService.connected().then(() => { | ||
```js | ||
/* service - app */ | ||
/* --- service-app --- */ | ||
const { ipcRenderer } = require('electron'); | ||
const { MessageChannel } = rrequire('electron-re'); | ||
const { MessageChannel } = require('electron-re'); | ||
@@ -112,3 +116,3 @@ // listen a channel, same as ipcRenderer.on | ||
/* service app2 */ | ||
/* --- service-app2 --- */ | ||
@@ -134,3 +138,3 @@ // handle a channel signal, just like ipcMain.handle | ||
```js | ||
/* render process */ | ||
/* --- render process --- */ | ||
const { ipcRenderer } = require('electron'); | ||
@@ -147,4 +151,6 @@ const { MessageChannel } = rrequire('electron-re'); | ||
``` | ||
#### Example | ||
check the `index.test.js` and `test` dir in root, there are some cases, you can run `npm run test` to see the test result of the library. | ||
#### III ) Example | ||
[electronux](https://github.com/NoJsJa/electronux) - this is a project of mine that uses `electron-re`, also you can check the `index.test.js` and `test` dir in root, there are some cases, then run `npm run test` to see test result of the library. | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
75422
0
149
10