Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

@nsisodiya/eventbus

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Issues
File Explorer

Advanced tools

@nsisodiya/eventbus

Simple EventBus for Node.js

    1.1.0latest

Version published
Maintainers
1
Yearly downloads
8,398
increased by1295.02%

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

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc