-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a promised based handle() #215
Add a promised based handle() #215
Conversation
…rted, return a Promise
If this project should stick with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great :-)
We'll need some tests for this functionality as well.
(There's not enough benefit in using the newer syntax versus the users it excludes, so let's continue using ES3 here)
are there other callback-taking APIs in this library that should get the same treatment? It'd be ideal to update them all at once.
The only other ones would be the Possibly one would then also allow validator methods to be Promises as they currently instead deliver the result through a Maybe fix |
Right, tests, I'll add, sorry for premature review request. Coming soon! |
@ljharb There, fixed In regards to As such I think a new issue / PR for that would make sense? Either one of us create an issue and then I can make a PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! i'll rebase with some changes.
1283079
to
f26c8cd
Compare
@voxpelli it's not a good idea to ship a Promise polyfill - especially since most people either won't need one, or will already be shipping their own. We can definitely look into |
f26c8cd
to
11200d8
Compare
Codecov Report
@@ Coverage Diff @@
## master #215 +/- ##
==========================================
+ Coverage 54.86% 55.19% +0.32%
==========================================
Files 12 12
Lines 1059 1069 +10
Branches 259 261 +2
==========================================
+ Hits 581 590 +9
- Misses 478 479 +1
Continue to review full report at Codecov.
|
I was thinking a ponyfill that would only be used when no global Promise is available, and justify that by the fact that the Should I create an issue for it then? |
Sure, we can discuss it there. |
Nowadays my feeling is that
promise
/async
/await
is pretty much the standard way of doing asynchronous development in node.js, so in my own projects and the projects I did at @Sydsvenskan I use a wrapper that makes.handle()
be promised based.This is that wrapper upstreamed to be part of
handle()
itself, making thecallbacks
argument optional and when it's omitted, instead a promise is returned.