JSPM

emitter-context

0.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q20097F
  • License MIT

Same as node Events with support for handler context

Package Exports

  • emitter-context

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 (emitter-context) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

emitter-context

This is a "fork" of node's Events module with support for specifying a context for the handler

API

Everything is the same as Events except:

emitter.addListener(event, listener, [ context ])

emitter.on(event, listener, [ context ])

emitter.once(event, listener, [ context ])

If the context is not specified, this (the emitter) will be used as the context.

var Emitter = require('emitter-context')
  , x = new Emitter()
;

var context = { foo: 'bar' };

x.on('baz', function () {
    console.log(this.foo);
}, context);

x.emit('baz');
// true - There are listeners for `baz`
// 'bar'