Giter Club home page Giter Club logo

Comments (10)

mcwhittemore avatar mcwhittemore commented on May 4, 2024

One thing I'm not sure about is what to call "events". The current debug code is using up and down but I'm not sure that is 100% clear to the end user. Client side talks about this as capturing and bubbling, but that doesn't seem right either. Is start and stop clear?

using on

var compose = require("koa-compse");

compose.on("down", function(ctx, name){ console.log(name, "has started"); });
compose.on("up", function(ctx, name){ console.log(name, "has finished"); });

using hook

var compose = require("koa-compse");

compose.hook(function(ctx, name, direction){
  if(direction=="down"){
    console.log(name, "has started");
  }
  else{
    console.log(name, "has finished");
  }
});

from compose.

tj avatar tj commented on May 4, 2024

we could implement it as more middleware that get injected inbetween, so you'd just do a normal yield. it feels super dirty to do this at the compose level though, I'd almost rather remove this library and have it be a thing in Koa. There's no guarantee that people will use compose() to compose middleware so unless we make it a formal thing it seems awkward

from compose.

mcwhittemore avatar mcwhittemore commented on May 4, 2024

I see the value of adding this to koa but how would koa inject debugging
into something like compose?

On Wed, Mar 12, 2014 at 9:59 PM, TJ Holowaychuk [email protected]:

we could implement it as more middleware that get injected inbetween, so
you'd just do a normal yield. it feels super dirty to do this at the
compose level though, I'd almost rather remove this library and have it
be a thing in Koa. There's no guarantee that people will use compose() to
compose middleware so unless we make it a formal thing it seems awkward

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-37492228
.

from compose.

PlasmaPower avatar PlasmaPower commented on May 4, 2024

Implemented in #51 and #52

from compose.

PlasmaPower avatar PlasmaPower commented on May 4, 2024

Is there any consensus on this yet? I'd like to get an implementation merged.

from compose.

PlasmaPower avatar PlasmaPower commented on May 4, 2024

With the Koa v2 release in sight, I'd like to get a wrapper implementation merged. How should I work towards this goal?

from compose.

fl0w avatar fl0w commented on May 4, 2024

Is this still an open issue, or could there be consensus on the hope of node 8's experimental async_hook to rescue the situation soon enough?

from compose.

PlasmaPower avatar PlasmaPower commented on May 4, 2024

I think async_hook is more diagnostic oriented. While useful, I think wrappers will have other uses.

from compose.

fl0w avatar fl0w commented on May 4, 2024

Heh, yea. To be fair, that was the only use case I had in mind anyway.

from compose.

bertho-zero avatar bertho-zero commented on May 4, 2024

There is @feathersjs/hooks which allows hooking any async function, based on koa-compose.

from compose.

Related Issues (20)

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.