UNPKG

toad-scheduler

Version:

In-memory Node.js and browser job scheduler

30 lines (29 loc) 1.19 kB
import { AsyncTask } from '../../common/AsyncTask'; import { Job, JobStatus } from '../../common/Job'; import { Task } from '../../common/Task'; import { SimpleIntervalSchedule } from './SimpleIntervalSchedule'; export type JobOptions = { preventOverrun?: boolean; id?: string; }; export declare class SimpleIntervalJob extends Job { private timer?; private readonly schedule; private readonly task; private readonly preventOverrun; constructor(schedule: SimpleIntervalSchedule, task: Task | AsyncTask, options?: JobOptions); /** * Start the job. * * Lifecycle invariant: the underlying timer is set up first, and any * `runImmediately` execution happens last. A `stop()` call issued from * inside the immediate task (sync) therefore finds an active timer to * clear, preventing the dangling-timer / double-run bug from #176. * `LongIntervalJob.start()` follows the same shape. */ start(): void; stop(): void; getStatus(): JobStatus; executeAsync(): Promise<void>; static createAndExecute(schedule: SimpleIntervalSchedule, task: Task | AsyncTask, options?: JobOptions): Promise<SimpleIntervalJob>; }