ppost
A simple central event emitter for electron
Last updated 9 years ago by jarends .
Unlicense · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ppost 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.3.0                                ...           latest (9 years ago)

6 Versions

  • 0.3.0                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |