-
Notifications
You must be signed in to change notification settings - Fork 220
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
.finalize(): Consider using the (err, data) callback style #7
Comments
errors are emitted as events so you can catch them with |
also, i do plan to make these |
It's not about not being able to catch errors. The problem with breaking the |
@danmilon fair point. i think i can make this happen as the next major release since it has breaking changes. would really love to have a few testers for this project to help make it more robust in the long term. |
you guys mention |
Definitely. |
ok then. ill see about making the needed changes and releasing v0.3.0 in the next two weeks. |
guys let me know what you think of the latest commits. |
Will do during the weekend. |
@danmilon thanks. i've overhauled the docs and examples too so let me know what you think and thanks for your feedback thus far. |
So, as of 51a7dbf, My suggested flow is:
This way errors will never pass silently. If there is no error event listener, the node core will throw it, by design. |
hum I define a fallback callback that throws err so eitherway works. not sure my pref at this moment. |
ah, indeed. Currently you cannot use the library without callbacks because of If I send a PR with the changes I proposed earlier will it be accepted? |
Dan, I have already implemented a true asynchronous way to use The basic approach is to keep an internal queue which adds each file after the last one is finished. Because of this, I can use Step (
function () {
var group_callback = this.group();
_.each(arr, function (val, key) {
archive.addFile(source, {
name: 'test'
}, group_callback());
});
}
); |
Please see my Pull request #8 for further information. Thank you. |
this callback style has been implemented in latest commits scheduled to be part of v0.3.0 |
Hello,
during my use of node-archiver I have noticed that the
.finalize()
function just returns one argumentwritten
to the callback function. This kind of stands out in the rest of my code, so I wonder if there aren't any errors which could possibly be thrown during execution of this function. If there are errors which can be thrown then in how far can we return them to the callback function? This might be a place to apply the widely-usedfunction (err, data) { .. }
callback style.If there are in fact no errors to return from this function, why is
.finalize()
asynchronous in the first place?I'm just wondering and hope you can point me in the right direction.
The text was updated successfully, but these errors were encountered: