🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@apio/bussy

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apio/bussy

An easy event bus with advance features

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
3
Created
Source

@apio/bussy

An easy events bus with advance features.

Installation

npm i @apio/bussy

Usage

EventBus

Generic events emitter. Support topic wildcards.

import Bussy from '@apio/bussy'

const events = Bussy.createEventBus()

events.on('test.*', (event, data) => {
  console.log(`New event: ${event}: ${data}`)
  // New event: test.a: sample data
})

events.emit('test.a', 'sample data')

DataBus

Typed data bus.

import Bussy from '@apio/bussy'

type User = {
  username: string
  password: string
}

const dataBus = Bussy.createDataBus<User>()

dataBus.listen((user: User) => {
  console.log(user.username, user.password)
})

dataBus.publish({ 
  username: 'username',
  password: 'password'
})

Request / Reply

Events bus implementing Request/Reply pattern.

import Bussy from '@apio/bussy'

const request = Bussy.createRequestBus<string, number>()

request.listen((data, reply) => {
  const len = data.length
  reply(len)
})

request.create('Messaggio', (res, err) => {
  if (err) {
    console.error(err)
  } else {
    console.log(res)
  }
})

// Or with a Promise version

try {
  const res = await request.createAsync('Messaggio async')
  console.log(res)
} catch (e) {
  console.error(e)
}

Todo

  • Implements timeout feature in Request/Reply pattern.

Keywords

apio

FAQs

Package last updated on 05 Mar 2025

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