Socket
Book a DemoInstallSign in
Socket

@tuxjs/eventbus

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tuxjs/eventbus

Event Bus for JavaScript

1.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@tuxjs/eventbus · Event Bus for Javascript, Typescript

EventBus is library support subcribe and publish event in Javascript, Typescript

Make sure your computer has a nodejs installed

Install nodejs in your computer click here

How to install @tuxjs/eventbus


npm install @tuxjs/eventbus

npm install @tuxjs/eventbus --save-dev

Guide use @tuxjs/eventbus in ES5


const EventBus = require('@tuxjs/eventbus');

const sub = EventBus.subcribe('event', (value) => {
    console.log('value: ' + value);
});

EventBus.publish('event', 'Hello es5');

sub.unsubcribe();

EventBus.publish('event', 'Hello es5 again');

Guide use @tuxjs/eventbus in ES6


import EventBus, { Subcriber } from '@tuxjs/eventbus';

const eventBus = new EventBus();

var sub1:Subcriber  = eventBus.subcribe('event1', (value: any) => {
    console.log('1: ' + value);
});

eventBus.subcribe('event1', (value: any) => {
    console.log('1: ' + value);
});

eventBus.subcribe('event2', (value: any) => {
    console.log('2: ' + value);
});

eventBus.subcribe('event3', (value: any) => {
    console.log('3: ' + value);
});


eventBus.publish('event1', 1);
eventBus.publish('event2', 'hello es6');
eventBus.publish('event3', "Hi");

sub1.unsubcribe();

console.log('-----');

eventBus.publish('event1', 100);
eventBus.publish('event2', 'hello es6 again');
eventBus.publish('event3', "Say goodbye");

eventBus.getSubcribers()

Thanks, click on the star button above to support me

Repository TuxJS-EventBus click here

Keywords

tuxjs

FAQs

Package last updated on 18 Jul 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.