0.0.2 • Published 9 years ago

context-events v0.0.2

Weekly downloads
2
License
-
Repository
github
Last release
9 years ago

context-events

Node's event emitter with optional context argument, like Backbone.

Forked from https://github.com/Gozala/events

Use require('context-events/monkey') to get a patched version of the original Events. Should be fully backwords compatible, only acts differently when given context argument.

Install

npm install context-events

Require

var EventEmitter = require('context-events')

Usage

See the node.js event emitter docs

Modified proto methods

All context arguments are optional

addListener / on / once (type, listener, context)

Set the context the listener will be called from it.

The first argument in the callback will be the callee. Example:

emitter.on('type', listener, context);
emitter.emit('type', arg1, arg2);
->
listener.call(context, emitter, arg1, arg2)

removeListener (type, listener, context)

Remove a listener added with a context

removeAllListeners (type, context)

Remove listeners with a certain context, type null for all

0.0.2

9 years ago

0.0.1

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago