Socket
Socket
Sign inDemoInstall

@tuxjs/eventbus

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tuxjs/eventbus

Event Bus for JavaScript


Version published
Weekly downloads
5
increased by400%
Maintainers
1
Install size
21.0 kB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 18 Jul 2019

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