@sovpro/ocafe

1.0.5 • Public • Published

Ocafe

Once a callback attached to the first emitted event

Build status for Node.js 0.x and newer

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.

Package Sidebar

Install

npm i @sovpro/ocafe

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

4.43 kB

Total Files

4

Last publish

Collaborators

  • sovpro