Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nazar-pc/async-eventer
A tiny library with asynchronous Promise-based implementation of events dispatching and handling
https://github.com/nazar-pc/async-eventer
async asynchronous dispatch event handle promise
Last synced: 30 days ago
JSON representation
A tiny library with asynchronous Promise-based implementation of events dispatching and handling
- Host: GitHub
- URL: https://github.com/nazar-pc/async-eventer
- Owner: nazar-pc
- Created: 2017-09-18T12:53:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-16T00:45:23.000Z (over 6 years ago)
- Last Synced: 2024-09-18T11:18:57.003Z (about 2 months ago)
- Topics: async, asynchronous, dispatch, event, handle, promise
- Language: LiveScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Async eventer [![Travis CI](https://img.shields.io/travis/nazar-pc/async-eventer/master.svg?label=Travis%20CI)](https://travis-ci.org/nazar-pc/async-eventer)
A tiny library with asynchronous Promise-based implementation of events dispatching and handling.This library works in Node and in Browser environments (UMD) and is optimized for very small size (under 1000 bytes raw, under 500 bytes gz).
## How to install
```
npm install async-eventer
```## How to use
Node.js:
```javascript
var Eventer = require('async-eventer')var instance = Eventer();
// Do stuff
```
Browser:
```javascript
requirejs(['async-eventer'], function (Eventer) {
var instance = Eventer();
// Do stuff
})
```## API
### Eventer.on(event: string, callback: Function) : Eventer
Register event handler.### Eventer.once(event: string, callback: Function) : Eventer
Register one-time event handler (just `on()` + `off()` under the hood).### Eventer.off(event: string[, callback: Function]) : Eventer
Unregister event handler.### Eventer.fire(event: string, ...param) : Promise
Dispatch an event with arbitrary number of parameters.`tests/index.ls` contains usage examples.
## Contribution
Feel free to create issues and send pull requests (for big changes create an issue first and link it from the PR), they are highly appreciated!When reading LiveScript code make sure to configure 1 tab to be 4 spaces (GitHub uses 8 by default), otherwise code might be hard to read.
## License
Free Public License 1.0.0 / Zero Clause BSD Licensehttps://opensource.org/licenses/FPL-1.0.0
https://tldrlegal.com/license/bsd-0-clause-license