Schedule
pulse.schedule(when, names, data?)
pulse.schedule(when, names, data?)
Example Usage
const pulse = new Pulse();
// Schedule a single job to run next Monday at 9 AM
const nextMonday = new Date();
nextMonday.setDate(nextMonday.getDate() + ((1 + 7 - nextMonday.getDay()) % 7 || 7));
nextMonday.setHours(9, 0, 0, 0);
pulse.schedule(nextMonday, 'weeklyMeetingReminder', { meetingId: 456 });
pulse.schedule('tomorrow at noon', [
'printAnalyticsReport',
'sendNotifications',
'updateUserRecords'
]);
Parameters
when
(string | Date
): The specific time when the job should be executed. This can be a string representing a date or aDate
object.names
(string | string[]
): The name or array of names of the job(s) to be scheduled. Each name corresponds to a job type previously defined with thedefine
method.data
(T
- optional): Data to pass to the job when it runs. This could be any type of data required by the job for its execution.
Returns
Promise<Job | Job[]>
: A promise that resolves with the created job or jobs. The promise will resolve after the job has been scheduled, or it will reject if there is an error during scheduling.
Last updated
Was this helpful?