eventemitter-co
EventEmitter with generator support
Last updated 8 months ago by frodon .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install eventemitter-co 
SYNC missed versions from official npm registry.

eventemitter with generator support (through co). eventemitter-co mimics require('events').EventEmitter API.

Build Status Coverage Status Version License

API

var sleep = require('nyks/function/sleep');

var Event = require('eventemitter-co');
var event = new Event();

var cafe = {color:'black'};
event.on("start", function*() {
  yield 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

  • 131
  • tj/co
  • uclass a pure JS/browser compliant class design syntax (ES6 classes with bindings)

Keywords / shout box

events, eventemitter2, co, generators, promise, binding

Current Tags

  • 2.0.3                                ...           latest (8 months ago)

6 Versions

  • 2.0.3                                ...           8 months ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |