Changed scheduleJob method signature to take when parameter first

no issue

- Accepting the schedule or a data when scheduled job should be run would follow a signature used in other established frameworks: (1) https://github.com/mperham/sidekiq/wiki/Ent-Periodic-Jobs#definition
- Another reason to put scheduling parameter first is this would allow leaving an optional "data" parameter as last
This commit is contained in:
Naz 2020-11-10 13:15:10 +13:00
parent 9abbe60e10
commit ae4f35ddd8
2 changed files with 4 additions and 4 deletions

View File

@ -44,11 +44,11 @@ class JobManager {
/**
* Schedules recuring job
*
* @param {Function|String} job - function or path to a file defining a job
* @param {Object} data - data to be passed into the joba
* @param {String} when - cron or human readable schedule format
* @param {Function|String} job - function or path to a file defining a job
* @param {Object} data - data to be passed into the job
*/
scheduleJob(job, data, when) {
scheduleJob(when, job, data) {
let schedule;
schedule = later.parse.text(when);

View File

@ -17,7 +17,7 @@ describe('Job Manager', function () {
const jobManager = new JobManager();
try {
jobManager.scheduleJob(() => {}, {}, 'invalid expression');
jobManager.scheduleJob('invalid expression', () => {}, {});
} catch (err) {
err.message.should.equal('Invalid schedule format');
}