Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/floatdrop/after-event
Execute function after event is emitted and on any proceeding call
https://github.com/floatdrop/after-event
Last synced: 22 days ago
JSON representation
Execute function after event is emitted and on any proceeding call
- Host: GitHub
- URL: https://github.com/floatdrop/after-event
- Owner: floatdrop
- Created: 2014-08-14T13:48:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-21T13:22:58.000Z (about 10 years ago)
- Last Synced: 2024-10-26T21:12:17.558Z (2 months ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# after-event [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
## Usage
```js
var after = require('after-event');
var events = require('events');
var ee = new events.EventEmitter();after(ee, 'bang', function (data) { console.log(data); });
ee.emit('bang', 'emitted bang'); // Logs `emitted bang` and saves arguments to proceeding calls
after(ee, 'bang', function (data) { console.log('other' + data); }); // Logs `other emitted bang` without emit called
ee.emit('bang', 'emitted bang 2'); // Stores new value
```## API
### after(eventemitter, event, cb)
Attaches event listener to `eventemitter` if such event was not emitted yet. Calls callback otherwise.
## License
MIT (c) 2014 Vsevolod Strukchinsky
[npm-url]: https://npmjs.org/package/after-event
[npm-image]: https://badge.fury.io/js/after-event.png[travis-url]: http://travis-ci.org/floatdrop/after-event
[travis-image]: https://travis-ci.org/floatdrop/after-event.png?branch=master