3.0.2 • Published 10 years ago
concierge v3.0.2
Concierge JS
A simple deferred async event emitting library
Installation
Node :
simply install through npm. ( node package manager )
npm install concierge
Browser :
download concierge.js and include it in your site directory
Loading
Node :
var concierge = require( 'concierge' ) ;
Browser :
<script src="concierge.js"></script>
Using
Transform any Object
into an event emitter with an interface of
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
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
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
o.off( 'uniqEvent', callback ) ;
o.off( 'uniqEvent' ) ;
concierge.emit
Will call all callbacks of the given event with all arguments following
o.emit( 'uniqEvent', arg1, arg2, ...) ;