Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nock/propagate
Propagate events from one event emitter into another
https://github.com/nock/propagate
emitter event eventemitter events propagation
Last synced: 6 days ago
JSON representation
Propagate events from one event emitter into another
- Host: GitHub
- URL: https://github.com/nock/propagate
- Owner: nock
- License: mit
- Created: 2013-01-08T16:44:19.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T21:48:54.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T12:10:26.631Z (7 months ago)
- Topics: emitter, event, eventemitter, events, propagation
- Language: JavaScript
- Size: 1.56 MB
- Stars: 21
- Watchers: 6
- Forks: 3
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# propagate
[![npm](https://img.shields.io/npm/v/propagate.svg?style=flat-square)][npmjs]
[![Build Status](https://img.shields.io/travis/nock/propagate/master.svg?style=flat-square)][build]
[![Coverage](https://img.shields.io/coveralls/github/nock/propagate.svg?style=flat-square)][coverage][npmjs]: https://www.npmjs.com/package/propagate
[build]: https://travis-ci.org/nock/propagate
[coverage]: https://coveralls.io/github/nock/propagatePropagate events from one event emitter into another.
## Install
```bash
$ npm install propagate
```## Propagate
```javascript
const ee1 = new EventEmitter()
const ee2 = new EventEmitter()
propagate(ee1, ee2)ee2.on('event', function(a, b) {
console.log('got propagated event', a, b)
})ee1.emit('event', 'a', 'b')
```## Unpropagate
You can unpropagate by ending the propagation like this:
```javascript
const ee1 = new EventEmitter()
const ee2 = new EventEmitter()
const p = propagate(ee1, ee2)// ...
p.end()
```## Only propagate certain events:
```javascript
const ee1 = new EventEmitter()
const ee2 = new EventEmitter()
const p = propagate(['event1', 'event2'], ee1, ee2)
```## Propagate certain events as other events:
```javascript
const ee1 = new EventEmitter()
const ee2 = new EventEmitter()
const p = propagate(
{
event1: 'other-event1',
event2: 'other-event2',
},
ee1,
ee2
)
```# License
MIT