Comments (10)
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.
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.
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 awkwardReply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-37492228
.
from compose.
from compose.
Is there any consensus on this yet? I'd like to get an implementation merged.
from compose.
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.
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.
I think async_hook
is more diagnostic oriented. While useful, I think wrappers will have other uses.
from compose.
Heh, yea. To be fair, that was the only use case I had in mind anyway.
from compose.
There is @feathersjs/hooks
which allows hooking any async function, based on koa-compose
.
from compose.
Related Issues (20)
- If `fn` is an asynchronous function, this `try catch` will be useless οΌ HOT 2
- I found that some code in the source code like `Promise.reject(),Promise.resolve()` seems redundant HOT 1
- Behavior changes on 4.2.0 HOT 5
- Add debug logs before and after each middleware executes HOT 1
- License is not included
- I donβt understand how the error is thrown when I find that next is called repeatedly. HOT 2
- Why use Promise.resolve() to wrap the execution results of each middleware? HOT 2
- Abnormal middleware errors occurred and KOA could not catch error events. How about the following changes
- [Question/Proposal] Sync/Async execution HOT 1
- Set default branch to next, default npm release to v3 HOT 1
- guard against unhandled next()s in development HOT 15
- Reorganize tests, and switch to Jest HOT 5
- when i use koa-compose with koa-router, koa-router does not work. HOT 6
- [Q&A] About Promise in the source code. HOT 1
- Outdated yield tests
- I can't catch the error ~ HOT 6
- Can't use destructuring with async await. HOT 2
- Unit test to verify if it handles wrapped non-async functions is wrong. HOT 1
- Control passed to handler before completing middleware chain HOT 4
- Multiple next with non async function HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose.