A simple extension of node's EventEmitter that permits setting the context of emitted events.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE.md
README.md
index.js
package.json
test.js

README.md

context-emitter stable

A simple extension of node's EventEmitter that permits setting the context of emitted events.

Installation

npm install context-emitter

Usage

ContextEmitter = require('context-emitter')

Returns the base class for the emitter.

emitter = new ContextEmitter([ctx])

You can either extend a class with ContextEmitter, or instantiate it directly. Either way, the first argument is optional and will set the context to run event handlers from.

emitter.ctx = context

Set the ctx property of the emitter to change emitted functions' contexts.