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

Other events #107

Open
acrodrig opened this issue Apr 8, 2020 · 4 comments
Open

Other events #107

acrodrig opened this issue Apr 8, 2020 · 4 comments

Comments

@acrodrig
Copy link

acrodrig commented Apr 8, 2020

It would be very nice to have the queue emit other events, such as empty.

@sindresorhus
Copy link
Owner

What other events than empty?

@acrodrig
Copy link
Author

acrodrig commented Apr 8, 2020

Sorry, I should have been more explicit. I like the active event. I wish I had other events such as idle and empty. For example, I would like to do something like:

queue.on('empty', () => {
    // Since the queue is empty, we have time for other things
    console.log(`Will flush out metrics/logs now!`);
    logger.flush();
    metrics.flush();
});

Does this make sense? I could do some promise "calisthenics" on top of the queue.onEmpty, but I would need to keep "awaiting" repeatedly to get a callback every time the queue becomes empty.

Cheers and thanks for a great library.

@Ilaiwi
Copy link
Contributor

Ilaiwi commented Apr 17, 2020

@acrodrig @sindresorhus I added idle event and submitted a PR with it #109

@shellscape
Copy link

I'd like to toss in a request for limitReached or some such that would notify when the queue is effectively paused because the intervalCap had been reached for a given interval. There's a good bit of processing that I'd like to do in that scenario.

jasonk added a commit to jasonk/p-queue that referenced this issue Oct 21, 2020
@jasonk jasonk mentioned this issue Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants