import { Disposable } from "../interfaces"; /** * Scheduler statuses */ export type Status = "running" | "paused" | "stopping" | "stopped"; /** * Scheduler actions */ export type Action = { id: string; action: () => Promise; callback?: (id: string, result: boolean | undefined) => void; delay?: number; }; /** * Schedules are queues of async actions that need to be executed sequentially * - Actions can be queued immediately or with a delay, callbacks inform when the action has been completed * - Action ids are unique, rescheduling cancels any pending actions with the same id * - A schedule rotates around `stopped` -> `running` -> `stopping` -> `stopped` -> ... * - You can `push` actions to a `stopped` or `running` schedule * - You can `stop` a `running` schedule, or it stops automatically when the queue is empty */ export interface Schedule extends Disposable { push: (action: Action) => void; stop: () => Promise; pause: () => void; resume: () => void; status: () => Status; pending: () => number; } /** * Schedule factory * @param name The name of the schedule * @returns A new schedule */ export declare const scheduler: (name: string) => Schedule; //# sourceMappingURL=scheduler.d.ts.map