https://github.com/alex-ray/concierge
A simple fast async deferred event emitting library
https://github.com/alex-ray/concierge
Last synced: 9 months ago
JSON representation
A simple fast async deferred event emitting library
- Host: GitHub
- URL: https://github.com/alex-ray/concierge
- Owner: Alex-ray
- License: other
- Created: 2014-04-17T17:41:03.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-12T21:44:31.000Z (over 11 years ago)
- Last Synced: 2025-04-18T02:02:15.530Z (9 months ago)
- Language: JavaScript
- Size: 395 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Concierge JS
A simple deferred async event emitting library
### Installation
**Node** **:**
simply install through npm. ( node package manager )
```javascript
npm install concierge
```
**Browser** **:**
download concierge.js and include it in your site directory
### Loading
**Node** **:**
```javascript
var concierge = require( 'concierge' ) ;
```
**Browser** **:**
```html
```
### Using
Transform any `Object` into an event emitter with an interface of
```javascript
var o = { } ;
concierge.convert( o ) ;
o.on {Function}
o.once {Function}
o.off {Function}
o.emit {Function}
```
### concierge.on
Takes an event and a callback that is called each time the event is emitted
```javascript
o.on( 'uniqEvent', function ( args ) {
// called when o.emit( 'uniqEvent', args ) is called
} ) ;
```
### concierge.once
Takes an event and a callback that is only called once
```javascript
o.once( 'uniqEvent', function ( args ) {
// only called once
} ) ;
```
### concierge.off
Takes an event and the function you want to stop listening to
if no function is passed in it will remove all listeners from that event
```javascript
o.off( 'uniqEvent', callback ) ;
o.off( 'uniqEvent' ) ;
```
### concierge.emit
Will call all callbacks of the given event with all arguments following
```javascript
o.emit( 'uniqEvent', arg1, arg2, ...) ;
```