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

@jojy/event-bus

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jojy/event-bus

A javascript eventBus

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

A javascript eventBus

A quick example

npm i @jojy/event-bus -S

import eventBus from '@jojy/event-bus';

// bind
eventBus.on('back', e => console.log(`1: ${e}`))
eventBus.on('back', e => console.log(`2: ${e}`), 1)  // just callback once
eventBus.on('back.pageA', e => console.log(`3: ${e}`))  // with namespace

// emit
eventBus.emit('back', 'test')
// 1: test  2: test  3: test

eventBus.emit('back', 'test')
// 1: test  3: test

eventBus.emit('back.pageA', 'test')
// 3: test

// unbound
eventBus.off('back.pageA')  // only unbound back.pageA
eventBus.off('back')  // unbound all back

Method

  • on(key, function, times),subscribe message
  • emit(key, data),publish message
  • off(key),remove the subscription

Introduction

  • support namespace, use key.namespace as a key, just like Jquery on.
  • can set callback times, for example: eventBus.on(key, callback, 1), it will execute once only.

Keywords

FAQs

Package last updated on 30 Jul 2021

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