Coder Social home page Coder Social logo

digitalbazaar / async-node-events Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joshuafcole/async-node-events

1.0 13.0 0.0 88 KB

Asynchronous cancelable (or not) EventEmitter-like object

Home Page: http://dfellis.github.com/async-cancelable-events

JavaScript 100.00%

async-node-events's People

Contributors

cl-joshcole avatar davidlehn avatar dlongley avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

async-node-events's Issues

Handle errors in `.on` Promise listeners.

The following code pattern, similar to that in bedrock-express, leads to an unhandled Promise rejection:

bedrock.events.on('foo', async () => {
  throw new Error('bar');
});

Consider more verbose emit return value.

Returning false as a signal a listener cancelled the event makes code difficult to understand. You must explicitly check for false, not just a falsey return value. Consider a more verbose return value like {cancelled: true/false}, and perhaps other details as needed.

Add "once" event hints.

Some events are known to be only sent once such as startup, ready, setup, and configuration events. When these are emitted it would be good to add a hint that these are only sent once. Code could then output a warning if there is a listener that is not using once(). This would help clean up some listener resources that are not needed for the full app life.

An API might be to use an object for emit. Something like:

events.emit({name: 'myevent', once: true}, ...args)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.