Package Exports
- async-listener
- async-listener/glue
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (async-listener) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
process.addAsyncListener polyfill
This is an implementation of Trevor Norris's process.{addAsyncListener,removeAsyncListener} API for adding behavior to async calls. You can see his implementation (currently a work in progress) on Node.js core pull request #6011. This polyfill / shim is intended for use in versions of Node prior to whatever version of Node in which Trevor's changes finally land (anticipated at the time of this writing as 0.11.7).
Here's his documentation of the intended API, which will probably get cleaned up here later:
createAsyncListener(listener[, callbacks[, storage]])
listener{Function}callbacks{Object}storage{Value}
Returns a constructed AsyncListener object. Which can then be passed to
process.addAsyncListener() and process.removeAsyncListener(). Each
function parameter is as follows:
listener(storage): AFunctioncalled as an asynchronous event is queued. If a {Value} is returned then it will be attached to the event asstorageand overwrite any pre-defined value passed tocreateAsyncListener(). If astorageargument is passed initially then it will also be passed tolistener().callbacks: AnObjectwhich may contain three optional fields:before(context, storage): AFunctionthat is called immediately before the asynchronous callback is about to run. It will be passed both thecontext(i.e.this) of the calling function and thestorageeither returned fromlisteneror passed during construction (if either was done).after(context, storage): AFunctioncalled immediately after the asynchronous event's callback is run. Note that if the event's callback throws during execution this will not be called.error(storage, error): AFunctioncalled if the event's callback threw. Iferrorreturnstruethen Node will assume the error has been properly handled and resume execution normally.
storage: AValue(i.e. anything) that will be, by default, attached to all new event instances. This will be overwritten if aValueis returned bylistener().
addAsyncListener(listener[, callbacks[, storage]])
addAsyncListener(asyncListener)
Returns a constructed AsyncListener object and immediately adds it to
the listening queue.
removeAsyncListener(asyncListener)
Removes the asyncListener from the listening queue.