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
ppost = require 'ppost' # emit in this window (ppost extends event) ppostemit 'event'args... # emit in process of window with id pposttoWin id'event'args... # emit in all processes pposttoAll 'event'args... # emit in all other windows processes and the main process, but not in this one pposttoOthers 'event'args... # emit in main process only pposttoMain 'event'args... # emit in all other window processes, but not in this one pposttoOtherWins 'event'args... # emit in all window processes, including this one, but not in main pposttoWins 'event'args...
Usage in main process
ppost = require 'ppost' # emit in main process only pposttoMain 'event'args... # or ppostemit 'event'args... # emit in all processes pposttoAll 'event'args... # emit in process of window with id pposttoWin id'event'args... # emit in all window processes pposttoAllWins 'event'args...
Synchronous ipc
in window: get value synchronously from main process
result = ppostget 'something'args...
in main: add a callback for the get
method
ppostonGet 'something' return something
Enjoy!
License
ppost is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.