Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sasaplus1/ipc-promise
ipc use as Promises
https://github.com/sasaplus1/ipc-promise
electron ipc javascript library promise
Last synced: 6 days ago
JSON representation
ipc use as Promises
- Host: GitHub
- URL: https://github.com/sasaplus1/ipc-promise
- Owner: sasaplus1
- License: mit
- Archived: true
- Created: 2015-06-05T10:55:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-02T04:28:38.000Z (almost 7 years ago)
- Last Synced: 2024-10-14T14:07:47.973Z (24 days ago)
- Topics: electron, ipc, javascript, library, promise
- Language: JavaScript
- Homepage:
- Size: 29.3 KB
- Stars: 35
- Watchers: 3
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
# ipc-promise
[![Build Status](https://travis-ci.org/sasaplus1/ipc-promise.svg)](https://travis-ci.org/sasaplus1/ipc-promise)
[![Dependency Status](https://gemnasium.com/sasaplus1/ipc-promise.svg)](https://gemnasium.com/sasaplus1/ipc-promise)
[![NPM version](https://badge.fury.io/js/ipc-promise.svg)](http://badge.fury.io/js/ipc-promise)ipc use as Promises
## Installation
### npm
```sh
$ npm install ipc-promise
```## Usage
### main process
```js
var ipcPromise = require('ipc-promise');ipcPromise.on('twice', function(params) {
return Promise.resolve(params.value * 2);
});var electron = require('electron'),
app = electron.app,
BrowserWindow = electron.BrowserWindow,
mainWindow;app.on('ready', function() {
mainWindow = new BrowserWindow({});
mainWindow.loadURL('file://' + __dirname + '/index.html');
});
```### renderer process
```html
ipcPromise
.send('twice', {
value: 1
})
.then(function(result) {
console.log(result); // => "2"
});```
## Functions
### on(event, listener)
- `event`
- `String` - event name
- `listener`
- `Function(*): Promise` - listener functionlisten event.
### send(event, data)
- `event`
- `String` - event name
- `data`
- `*` - data for send
- `return`
- `Promise` - Promisestrigger event.
## Test
```sh
$ npm install
$ npm test
```## License
The MIT license. Please see LICENSE file.