@sovpro/ocafe
v1.0.5
Published
Once a callback attached to the first emitted event
Downloads
4
Maintainers
Readme
Ocafe
Once a callback attached to the first emitted event
Usage
var cancel = ocafe (
event_emitter
, 'thisEvent'
, thisEventCallback
, { event: 'thatEvent' ,
callback: thatEventCallback }
)
Parameters
Event Emitter
The first parameter must be an object that inherits EventEmitter or implements the EventEmitter interface.
Event names and callbacks
Event names and callbacks may be passed as ordered arguments and/or objects having an event
and callback
property.
Cancellation
var cancel = ocafe (
event_emitter
// , [name], [callback]
// , [name], [callback]
)
// cancelled is true if called before
// any of the events above emitted
var cancelled = cancel ()
ocafe
returns a cancel
function that, if called before one of the events is emitted, will prevent the callbacks passed as arguments from being run.