1.0.5 • Published 4 years ago

@sovpro/ocafe v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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.