1.0.5 • Published 5 years ago
timable v1.0.5
Timable
Timable is a module that allow user to schedule a job on specific time ( or moment)
Install
npm install timable
Usage
Here is an example on Timable.
const
Timable = require('timeable'),
moment = require('moment');
const job = Timable.schedule(
function(){
console.log('Hello');
},
moment().add(3, 'seconds')
);
job.on('invoke', function(){
console.log('Job has invoked');
});
job.on('error', function(error){
console.error(error);
});
job.on('cancel', function(){
console.log('Job has canceled');
});
API
Events
job.on("invoke", function())
Triggered when the job is invoked
job.on("error", function())
Triggered when error caused on executing the job
job.on("cancel", function())
Triggered when user call the cancel() method
Functions
job.invoke()
Invoke the job immediately
job.cancel()
Cancel the job, and the job would remove from the scheduledJobs
Licence
MIT