Jobs
Jobs are a simple way to run code asynchronously on a set schedule, or whenever you need to.
Basic setup
In practise
import { ScheduledJob } from './base'
const job = new ScheduledJob('a_scheduled_job', 1000, async () => {
// do some work every second
})
job.start()
export default jobimport { Job } from './base'
const job = new Job('a_job', async () => {
// do some work
})
export default job
// elsewhere in the code:
import { jobs } from '../cache'
const job = jobs.get('a_job')
job?.run()Last updated
Was this helpful?
