ppost

0.3.0 • Public • Published

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) 
    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

 
    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

    result = ppost.get 'something'args...

in main: add a callback for the get method

    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.

Dependents (0)

Package Sidebar

Install

npm i ppost

Weekly Downloads

3

Version

0.3.0

License

Unlicense

Last publish

Collaborators

  • jarends
  • monsterkodi