-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Feature request: onComplete callback #130
Comments
There is no such functionality right now. But there is a simple solution to try, which might or might not work for your use case. The job will be passed as the first parameter to the triggered function, use that and check for Disclaimer: Totally untested 😄 |
Ah great, that seems like it should work. I was also going to try using |
Cool! Keep us updated on which path you choose, and leave the issue open. |
I've looked into this a bit deeper now. I actually think one of the simplest and cleanest solutions would be to implement this where it's needed. Something like: import Cron from "croner";
const job = new Cron("0/5 * * * * *", { maxRuns: 2 }, (job) => {
// Do work
console.log('Job Running');
// Is this the last execution?
if (!job.next()) {
console.log('Last execution');
}
});
// Will there be no executions?
if (!job.next() && !job.previous()) {
console.log('No executions scheduled');
} |
Fixed by new example in docs at https://github.com/Hexagon/croner#act-at-completion |
This is more of a question and/or possible feature request. Does Croner have an
onComplete
type callback ability? Essentially I'm looking to run this job x amount of times usingmaxRuns
however on the last run if my tasks are not complete I will need to perform other tasks. So without keeping an internal count of the runs and then running if it hits its max I would like to use themaxRuns
option and then pass another callback function to on ifmaxRuns
has reached it's end. Thanks!The text was updated successfully, but these errors were encountered: