@beardedtim/eventter

0.0.1 • Public • Published

Eventter

Usage

const makeEmitter = require('@beardedtim/eventter');

// No `new` keyword. It's just a function
const emitter = makeEmitter();
// We register to some event
emitter.on('someEvent', (a, b, c) => {
  // a === 1, b === 2, c === 3
  // ...
});
// ...
// Then at some point we emit the event
emitter.emit('someEvent', 1, 2, 3);

API

As closely as possible, this repo tries to match the node API for events. However, do note that this package does not return a class or any reference to this and probably can't be chained without a HoF/helper. You can see the API and what each method does by looking at the test file.

To Note: If you give your listeners the property fn.once = [truthy value], they will be treated as if you had ran once(event, fn) instead of on(evcent, fn).

Roadmap

  • [ ] Add context to EventEmitter ( this for all handlers)
  • [ ] add context to listeners ( this for specific handler)

Dependents (0)

Package Sidebar

Install

npm i @beardedtim/eventter

Weekly Downloads

2

Version

0.0.1

License

MIT

Last publish

Collaborators

  • beardedtim