https://github.com/xfoxawy/eventbusjs
Simple Pub/Sub Event Bus as mediator pattern
https://github.com/xfoxawy/eventbusjs
javascript mediator mediator-pattern pub pubsub
Last synced: 5 months ago
JSON representation
Simple Pub/Sub Event Bus as mediator pattern
- Host: GitHub
- URL: https://github.com/xfoxawy/eventbusjs
- Owner: xfoxawy
- Created: 2018-11-06T06:06:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T04:52:41.000Z (about 7 years ago)
- Last Synced: 2025-09-17T01:58:18.774Z (9 months ago)
- Topics: javascript, mediator, mediator-pattern, pub, pubsub
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## SimpleEventBusJs
Simple Pub/Sub Event Bus as mediator pattern, it can be used as mediator module to communicate between different modules, its easy to use.
Inspired by Laravel EventBus
### Installation
npm install simpleeventbusjs
### Usage
- Import `var EventBus = require('simpleeventbusjs');`
- create new instance `let eb = new EventBus();`
- Subscribe to a channel `eb.subscribeToChannel('test_channel', my_cb)`
- Subscribe to specific event on a channel `eb.subscribeToEvent('test_channel', 'test_event', my_cb)`
- Subscribe to all events from all channels `eb.subscribeToChannel('*', my_cb)`.
- Push events `eb.pushEvent('test_channel', 'test_event', {data : 'success'})` and it will automatically invoke subscribed callbacks.
-