Skip to content

carloslfu/pullable-event-bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pullable Event Bus

A minimal event bus where emmiters can pull data from subscribers

  1. Install it with: npm i --save pullable-event-bus or yarn add pullable-event-bus
  2. Import it:
// ES6
import { makeEventBus } from 'pullable-event-bus'
// Node.js
const { makeEventBus } = require('pullable-event-bus')
  1. Use it:
const eventBus = makeEventBus()
// subscribers
eventBus.on('channel', data => console.log(data))
eventBus.on('channel', data => data + 1, true) // true means is a pullable subscriber
// emit a message
eventBus.emit('channel', 10).then(results => console.log(results))
// logs:
// 10 from first subscriber
// [11] as the result of emitting the message and the '11' comes from the second (the pullable) subscriber

Have fun!

About

An event bus where emitters can pull data from subscribers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published