Cancel node-schedule event after it has been set
See original GitHub issueI am planning on using node-schedule to set up push notifications for appointment reminders as follows:
var schedule = require('node-schedule');
var date = req.body.date; // Date for reminder from client request
var j = schedule.scheduleJob(date, function(){
// Send push notification
});
Now I know you can cancel the event by calling cancel():
j.cancel()
However, how can I refer to that specific job to cancel if the user from the client side decides to change the appointment to a different date later on?
For example user wants to set a reminder for December 25th 2015, then a few days later they decide to change the reminder to December 24th, 2015.
How can I reference the event that was scheduled for December 25th, 2015 and cancel it and create a new one for December 24th, 2015.
Thanks in advance for your help!
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Cancel node-schedule event after it has been set
@ShahNewazKhan it seems it doesn't work with node-schedule version 1.3.2. if there is a unique_name parameter, function is not called at specified date...
Read more >Cancel node-schedule event after it has been set-node.js
Coding example for the question Cancel node-schedule event after it has been set-node.js.
Read more >node-schedule - npm
Node Schedule is a flexible cron-like and not-cron-like job ... A canceled event when an invocation is canceled before it's executed.
Read more >How to use the node-schedule.cancelJob function in ... - Snyk
To help you get started, we've selected a few node-schedule.cancelJob examples, based on popular ways it is used in public projects.
Read more >Scheduling Jobs with Node.js - Reflectoring
For example, if the asterisk symbol is in the “month” field, it means the task is run every month. , : The comma...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ShahNewazKhan I’m not sure I understand correctly what the problem is:
In case your problem is the first one, I don’t think there’s a way to do that: you could have multiple job scheduled for the same time. In order to retrieve a specific job, you could always create it with a unique name and you could always retrieve it later via that unique name:
In case you want to be able to reschedule the job, there’s no specific method, but you can do:
long-hand is here https://github.com/node-schedule/node-schedule/issues/192#issuecomment-150762650 @esatterwhite