Socket
Socket
Sign inDemoInstall

@nsisodiya/eventbus

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nsisodiya/eventbus

Simple EventBus for Node.js


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
14.9 kB
Created
Weekly downloads
 

Readme

Source

@nsisodiya/eventbus

Simple EventBus for Node.js

Installation

npm install --save @nsisodiya/eventbus

Usage

import EventBus from '@nsisodiya/eventbus';


var b1 = new EventBus();

var unsub1 = b1.subscribe("ADD_EVENT", function (obj) {
	console.log("AddEvent Received at Section 1", obj);
});


var unsub2 = b1.subscribe("ADD_EVENT", function (obj) {
	console.log("AddEvent Received at Section 2", obj);
});


var unsub3 = b1.subscribeAll(function (obj, obj2) {
	console.log("Some Event Received at Section 3", obj, obj2);
});


b1.publish("ADD_EVENT", {done: false, title: "write JS"});
/*
AddEvent Received at Section 1 Object {done: false, title: "write JS"}
AddEvent Received at Section 2 Object {done: false, title: "write JS"}
Some Event Received at Section 3 ADD_EVENT Object {done: false, title: "write JS"}
*/

b1.publish("EDIT_EVENT", {done: false, title: "write JS"});
/*
Some Event Received at Section 3 EDIT_EVENT Object {done: false, title: "write JS"}
*/


unsub1();

b1.publish("ADD_EVENT", {done: false, title: "write JS"});
/*
AddEvent Received at Section 2 Object {done: false, title: "write JS"}
Some Event Received at Section 3 ADD_EVENT Object {done: false, title: "write JS"}
*/


unsub3();

b1.publish("EDIT_EVENT", {done: false, title: "write JS"});

/*
No Output and no one subscribe this event.
*/

Keywords

FAQs

Last updated on 11 Mar 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc