eventemitter-async

2.1.0 • Public • Published

eventemitter with async/await. eventemitter-async mimics require('events').EventEmitter API.

Build Status Coverage Status Version License

API

var sleep = require('nyks/async/sleep');
var Event = require('eventemitter-async');
var event = new Event();

var cafe = {color:'black'};
event.on("start", async function() {
  await sleep(1);
  console.log("Hi, coffee is ", this.color);
}, cafe);


event.emit("start");

Errors (&promises)

event.emit() will return a promise you can work with if you need to handle errors

Notes

You can set an optional 3rd parameter and set the context ("this") in event registration.

Credits

Keywords / shout box

events, eventemitter2, uclass, promise, binding

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.1.0
    17
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.1.0
    17
  • 2.0.1
    1
  • 2.0.0
    0

Package Sidebar

Install

npm i eventemitter-async

Weekly Downloads

17

Version

2.1.0

License

ISC

Unpacked Size

6.08 kB

Total Files

9

Last publish

Collaborators

  • 131
  • frodon