New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

electron-pubsub

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-pubsub

Pubsub for electron

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

electron-pubsub

Pubsub for Electron.

You can use it in main or renderer process.

Usage

Initialization

npm install --save electron-pubsub

// in main process
const pubsub = require('electron-pubsub');

// in renderer process
const pubsub = require('electron').remote.require('electron-pubsub');

Subscribe

pubsub.subscribe('myTopic', (event, ...args) => {
    // do something here.
});

pubsub.once('anotherTopic', someCallback);

Publish

// in any process
pubsub.publish('myTopic', 'some arguments');

Unsubscribe

// in any process
pubsub.unsubscribe('myTopic', someCallback);
pubsub.unsubscribe('myTopic');

pubsub.clearAllSubscriptions();

Hierarchical addressing

pubsub.subscribe('a', myFunc1);
pubsub.subscribe('a.b', myFunc2);
pubsub.subscribe('a.b.c', myFunc3);

pubsub.unsubscribe('a.b');

Use promises

pubsub.publish('myTopic', 'some arguments')
    .then(onSuccess)
    .catch(onFailure);

pubsub.subscribe('myTopic', (event, ...args) => {
    event.resolve('success!');
});

TODO

  • Support hierarchy of topics.

Keywords

FAQs

Package last updated on 29 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc