-
Notifications
You must be signed in to change notification settings - Fork 57
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
Remove error from callbacks that don't return an error #70
Comments
|
My only thought to make it optional would be a flag to the Would you be fine with the flag being opt out, so that new users don't need to worry about the
For (2), if the behavior was opt in, then I'm not sure there's a way in TS to properly model this behavior that it renders it a lot less useful to me personally that I'd probably not bother with a PR to do this, and would then just leave it at the current status quo. |
|
This would only work in the case where a callback only has two arguments (just const callback = () => {};
callback(1, 2, 3, 4, 5); is perfectly valid JS. As a further example, my current usage of the library looks like this: client.execute({
query: statement,
state: (_, query_id) => {
// save query_id for later use
},
columns: (_, columns) => {
// save columns for later use
},
data: (_, data) => {
// buffer data until we hit success
},
error: (error) => {
// raise an error
},
success: () => {
// process our buffered data, return to caller
}
}); So in this case, the callback |
Oh, wow, I missed the case to have fewer arguments than documents intentionally. |
Looking at the source code, I noticed that for the
execute
function the following callbacks:state
columns
data
all document that their first argument is
error
. However, in all cases, they only ever receivenull
, and that if there was an error, it would have gone to theerror
/callback
callback function, and then the above callbacks are never called.My proposal would be to remove the first argument from those callbacks as it simplifies the call signature as well as better indicates to downstream users that they don't need to worry about any sort of error handling along those callbacks.
The text was updated successfully, but these errors were encountered: