Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/event-pipeline
A simple event emitter which processes events in order
https://github.com/wankdanker/event-pipeline
Last synced: 14 days ago
JSON representation
A simple event emitter which processes events in order
- Host: GitHub
- URL: https://github.com/wankdanker/event-pipeline
- Owner: wankdanker
- Created: 2017-06-20T00:01:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-17T21:56:56.000Z (about 5 years ago)
- Last Synced: 2024-11-06T01:17:19.247Z (2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
event-pipeline
--------------This module provides an event-emitter like class that processes registered
event handlers in order and returns a callback to the emit call when all events
have been called. If an event handler passes an error to the callback function
then no further event handlers will be called.example
-------```js
var EventPipeline = require('event-pipeline');var e = new EventPipeline();
e.on('get:before', function (arg1, arg2, cb) {
/* stuff */return cb();
})e.on('get:before', function (arg1, arg2, cb) {
/* stuff */return cb();
})var a = {};
var b = {};e.emit('get:before', a, b, function (err, a, b) {
//done
});
```api
---* EventPipeline() - constructor function
* on(eventName, listener) - register a listener
* eventName - the event name to register
* listener - the function to call when eventName is emitted
* on.unshift(eventName, listener) - insert a listener to the beginning of the list of listeners
* eventName - the event name to register
* listener - the function to call when eventName is emitted
* off(eventName, listener) - unregister a listener
* eventName - the event name that was previously registered
* listener - the function that was previously registered
* emit(eventName[, arg1][, arg2][, ...][, callback]) - emit an event
* arg1, ... - all arguments are passed to the event listener
* callback - this function is called when all events have been processed or
one of them called back with an errorlicense
-------MIT