Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-re

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-re - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

LICENSE.md

8

package.json
{
"name": "electron-re",
"version": "1.0.2",
"version": "1.0.3",
"description": "electron sugar utils",

@@ -14,3 +14,3 @@ "main": "./lib/index",

"author": "NoJsJa",
"license": "ISC",
"license": "MIT",
"repository": {

@@ -21,2 +21,5 @@ "type": "git",

"homepage": "https://github.com/NoJsJa/electron-re#readme",
"dependencies": {
"electron": "8.2.0"
},
"devDependencies": {

@@ -27,5 +30,4 @@ "babel-preset-es2015": "^6.24.1",

"cross-env": "^7.0.2",
"electron": "8.2.0",
"electron-mocha": "^9.3.2"
}
}
### electron-re
---------------
Using `electron-re` to generate some service processs and communicate between `main process`,`render process` and `service`. In some `Best Practices` of electron tutorials, it suggest to put your code that occupy the CPU into rendering process instead of in main process, exactly `electron-re` means to do.
> can only be used in electron project and test on electron@8.2.0
Using `electron-re` to generate some service processs and communicate between `main process`,`render process` and `service`. In some `Best Practices` of electron tutorials, it suggests to put your code that occupy the CPU into rendering process instead of in main process, exactly `electron-re` means to do.
#### I ) Instruction

@@ -44,3 +45,3 @@

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')`
In order to send data from main/other process to a service you need to use `MesssageChannel`, such as: `MessageChannel.send('service-name', 'channel', 'params')`

@@ -51,8 +52,17 @@ #### II ) Usage

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.
The service is a customized `BrowserWindow` instance, initialized by a file worked with `commonJs` module, so you can use `require('name')` and can't use `import some from 'name'` syntax. It has two extension methods:
* `connected()` - return a resolved `Promise` when service is ready.
* `openDevTools` - open an undocked window for debugging.
suggest to put some business-related code into a service.
```js
/* --- main.js --- */
const { BrowserService } = require('electron-re');
const {
BrowserService,
MessageChannel // must required in main.js even if you don't use it
} = require('electron-re');
...

@@ -85,8 +95,13 @@

##### 2. MessageChannel
> confirm to require it in main.js(main process entry) first
This is a messaging tool expanding some method from electron build-in ipc:
This is a messaging tool expanding some methods from electron build-in ipc:
```js
/* --- main --- */
const { BrowserService, MessageChannel } = require('electron-re');
const {
BrowserService,
MessageChannel // must required in main.js even if you don't use it
} = require('electron-re');
const isInDev = process.env.NODE_ENV === 'dev';
...

@@ -139,3 +154,3 @@

// send data to another service and return a promise , just like ipcRenderer.invoke
MessageChannel.invoke('app2', 'channel3' (event, result) => {
MessageChannel.invoke('app2', 'channel3', { value: 'channel3' }).then((event, result) => {
console.log(result);

@@ -172,3 +187,3 @@ });

const { ipcRenderer } = require('electron');
const { MessageChannel } = rrequire('electron-re');
const { MessageChannel } = require('electron-re');

@@ -186,3 +201,3 @@ // send data to a service

[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.
[electronux](https://github.com/NoJsJa/electronux) - 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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc