-
Notifications
You must be signed in to change notification settings - Fork 167
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
Promise / async/await support #200
Comments
Your wrapper isn't correct (it ignores error cases), and I wouldn't bother with boundedForm.validate = function () {
return new Promise((resolve, reject) => {
validate((err, result) => {
if (err) { reject(err); } else { resolve(result); }
});
});
}; This library works down to node 0.4 - using
None of those seem particularly desirable just to avoid a few lines of code :-/ |
Thank you for your reply!
It resolves errors (It doesn't throw them).
I think we could use semver. I mean we can say
Oh, yeah 😸 |
Right, it's not correct if Of course we can use semver; that's what I meant by "breaking change". But, I'd prefer not to exclude the folks that are still using old node versions. |
I'm 👍 on this, especially as the oldest LTS release at the moment, for about 3 more months, is Node.js 10.x and it supports most modern API:s https://node.green/ I would actually propose making a
I made a related PR: #215 Also, I'm offering help in making this move and to help this module move forward. Maybe we could move this module to a GitHub organization @caolan? |
I'm not a fan of either dropping support or making breaking changes. It should be possible to support combination callback/Promise APIs. |
@ljharb In a modules public API:s, I generally agree, but in internal API:s one can make a complete swap if one sees a benefit of it. (One benefit would be that one eg. could use linting rules to enforce a specific style consistently) It’s also a matter of managing complexity I think. Is it best handled by forcing users to upgrade to a new API or by managing two styles side by side? When the migration doesn’t require a lot of work that equation starts to lean in favor of dropping old API:s I think, but it can vary from API to API. |
True, but until a package adds the "exports" field in package.json (which is semver-major), there's no such thing as "internal APIs". |
Depends on how one judges the gray area of “non-documented, yet possible to use anyway” API:s. I import files from forms directly in projects of mine, not because I think that’s supported, but because I was prepared to take the risk of it breaking on every single update, and thus having the intention of upstreaming all such uses and enable documented public API:s for those things. Just because one can use something one wasn’t intended to one doesn’t have to face no consequences for doing so? |
If it's reachable, it's public ¯\_(ツ)_/¯ certainly a maintainer could choose to be capricious and break someone knowingly, but i certainly wouldn't do that. |
Right, with that stance I would say that from a complexity standpoint it wouldn’t be feasible to make a move towards a promise based API for this module, if one would then still have to also maintain every callback in every function in every file. I would love an evolution of the current API that fits better into the current shape of Node.js projects. How would one best achieve that would you say @ljharb? A new module then rather than a breaking change here? |
Give me a bit of time to review your current PRs, and also review the codebase to see what might be a viable approach. |
Hi,
Thanks for this library!
I use koa@2 that supports async/await syntax. My use case is:
What do you think about support of promises (promisification)?
Currently, I forced to use my wrapper around this library. It promisifies
validate
function:The text was updated successfully, but these errors were encountered: