https://github.com/richienb/electron-messages
Evaluate some code in an Electron context with inter-process messaging.
https://github.com/richienb/electron-messages
Last synced: 3 months ago
JSON representation
Evaluate some code in an Electron context with inter-process messaging.
- Host: GitHub
- URL: https://github.com/richienb/electron-messages
- Owner: Richienb
- License: mit
- Created: 2020-11-07T04:51:55.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-21T14:18:17.000Z (over 3 years ago)
- Last Synced: 2025-10-02T06:27:30.143Z (4 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# electron-messages [](https://travis-ci.com/Richienb/electron-messages)
Evaluate some code in an Electron context with inter-process messaging.
[](https://npmjs.com/package/electron-messages)
## Install
```sh
npm install electron-messages
```
## Usage
```js
const electronMessages = require("electron-messages")
const electronInstance = await electronMessages(async ipc => {
// You can use Electron APIs here
ipc.emit("unicorn", {
hello: "world"
})
})
// Logs `{ hello: "world" }`
electronInstance.on("unicorn", data => {
console.log(data)
})
```
## API
### electronMessages(function_, arguments_, options?)
#### function_
Type: `(ipc, ...arguments_) => any | Promise`
The function to evaluate in the Electron context. The first argument will be an ipc controller that allows you to `.emit` events and listen for them with `.on`. The other arguments are set to the value of `arguments_`.
#### arguments_
An array of arguments to include as arguments when calling `function_`.
#### options
Type: `object`
Options to pass to [`new BrowserWindow()`](https://github.com/electron/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions).