Skip to content
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

params for job callback not documented #88

Open
Sleepful opened this issue Dec 8, 2022 · 4 comments
Open

params for job callback not documented #88

Sleepful opened this issue Dec 8, 2022 · 4 comments

Comments

@Sleepful
Copy link

Sleepful commented Dec 8, 2022

from the docs:

q.push(function (cb) {
  const result = 'two'
  cb(null, result)
})

so it is implied that the second parameter of cb should be the value that will end up on q.results, but what does the first parameter of cb mean (with null value in the example)?

I assume the first param would take an error if there was one. But I dunno.

@mgrist
Copy link

mgrist commented Jan 13, 2023

I was confused by this as well, I am glad I am not the only one. The documentation for this library isn't the greatest.

@jessetane
Copy link
Owner

back in the old days, before promises got popular, we used the callback pattern to write async code. this pattern was so universal at that time that it did not make sense to document it here. here's a reference if you're curious about the pattern: https://nodejs.dev/en/learn/javascript-asynchronous-programming-and-callbacks/#handling-errors-in-callbacks

@jessetane
Copy link
Owner

i'm hoping someone will come along and rewrite this module to be a bit more promise oriented since that's what most folks are using today... read #86 and send a pr!

@mgrist
Copy link

mgrist commented Jan 13, 2023

That makes sense. I read some of your other comments and I ended up using Promise.all() instead of the queue library, but it was fun to play around with. Thanks for the knowledge on the callback pattern though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants