ppost
所属分类:人工智能/神经网络/深度学习
开发工具:CoffeeScript
文件大小:4KB
下载次数:0
上传日期:2017-04-22 12:22:28
上 传 者:
sh-1993
说明: 一种简单的电子中心事件发射体
(A simple central event emitter for electron)
文件列表:
UNLICENSE.txt (1210, 2017-04-22)
coffee (0, 2017-04-22)
coffee\ppost.coffee (3752, 2017-04-22)
js (0, 2017-04-22)
js\ppost.js (6319, 2017-04-22)
package.json (580, 2017-04-22)
# ppost
A simple central event emitter for electron, which can post messages via ipc to the main process or other windows.
**Usage in renderer process**
```coffee
ppost = require 'ppost'
# emit in this window (ppost extends event)
ppost.emit 'event', args...
# emit in process of window with id
ppost.toWin id, 'event', args...
# emit in all processes
ppost.toAll 'event', args...
# emit in all other windows processes and the main process, but not in this one
ppost.toOthers 'event', args...
# emit in main process only
ppost.toMain 'event', args...
# emit in all other window processes, but not in this one
ppost.toOtherWins 'event', args...
# emit in all window processes, including this one, but not in main
ppost.toWins 'event', args...
```
**Usage in main process**
```coffee
ppost = require 'ppost'
# emit in main process only
ppost.toMain 'event', args...
# or
ppost.emit 'event', args...
# emit in all processes
ppost.toAll 'event', args...
# emit in process of window with id
ppost.toWin id, 'event', args...
# emit in all window processes
ppost.toAllWins 'event', args...
```
**Synchronous ipc**
in window: get value synchronously from main process
```coffee
result = ppost.get 'something', args...
```
in main: add a callback for the `get` method
```coffee
ppost.onGet 'something', (args...) -> return something
```
Enjoy!
### License
ppost is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.
近期下载者:
相关文件:
收藏者: