-
Notifications
You must be signed in to change notification settings - Fork 58
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
Use promises and async/await instead of callbacks where applicable #84
Comments
The right approach here probably depends on the question I posed in #100 — do we want to do a non-breaking 0.10.2 release (in which case I should implement this in a way that supports both promise-based and callback-based usage), or make the next release 0.11.0 and include breaking changes (in which case I do this with nicer @ErikBoesen any feedback on that? |
My inclination is that we should support both syntaxes. |
Just to make sure I’m following, are you saying:
I might not have said this clearly before, but I think (1) is fine, but am not a fan of (2). Specifically, I think the value of this issue (use promises and async/await) as well as #83 (class syntax) as #85 (update linting tools) are in making the code easier to maintain because they make it harder to make mistakes (otherwise these issues are all just yak-shaving, and we should close them instead of doing them!). Supporting both callbacks and promises is relatively complicated: you have to not return a promise if someone passes in callbacks, because returning a promise that rejects can crash someone’s program if they don’t handle the rejection, which they will not have done if they passed in a callback. It makes the code more error-prone, rather than less. Given the maintenance status of this package, I think simpler-to-maintain code is more valuable than flexible-but-has-edge-cases code. (I think async/await is simplest to maintain and least error prone, while sticking to callbacks is still less error prone than doing both.) |
That is a fair argument; seems like it would be best to fully replace them and do a breaking release. (As I understand it, isn't the first component of the semantic version for breaking changes, so this would be v1.0.0?) |
In semver, the rules are different before v1 vs. after:
Since we are at v0.10.1, you can “safely” do a breaking change in v0.11.0. (Or: you should only go to v0.11.0 if you have breaking changes. If you don’t you should go to v0.10.2.) |
Gotcha, sounds good! |
OK, so no v0.10.2; we’re just going straight to v0.11.0 as the next release? |
Promises and the
async
/await
keywords are supported in all versions of Node.js this package is compatible with, and it would probably be good to use them instead of callbacks (e.g. inBufferedMetricsLogger.flush()
. We can also support both.The text was updated successfully, but these errors were encountered: