UNPKG

@pubby/sdk

Version:
41 lines (40 loc) 1.46 kB
import { Pubby } from "../../client"; import { PubbyModule } from "../../module"; import { Schedule, ScheduleInterval, ScheduleOptions, ScheduleTimeout } from "./types"; declare module "../../client" { interface Pubby { scheduler: SchedulerModule; } } export declare class SchedulerModule extends PubbyModule<ScheduleOptions> { private intervalUpdate; private pendingCalls; private tasks; constructor(pubby: Pubby, options: ScheduleOptions); /** Retorna o tempo atual */ get now(): number; /** Iniciar agendador quando o módulo for inicializado */ init(): void; /** Inicia o agendador, caso ele esteja parado */ start(): this; /** Para o agendador */ stop(): this; /** Executa uma task */ private run; /** Atrasa a execução de uma task */ private callAfterTime; /** Atualiza o agendador */ update(time?: number): this; /** Define uma nova tarefa */ set(task: Schedule): this; /** Executa uma tarefa se estiver na hora */ requestRun(task: Schedule, time?: number): void | this; /** Define uma tarefa de repetição */ interval(task: ScheduleInterval): this; /** Define uma tarefa que será executada após algum tempo apartir do tempo atual */ timeout(task: ScheduleTimeout): this; /** Cancela uma tarefa */ cancel(id: string): this; /** Cancela todas as tarefas */ clear(): this; }