UNPKG

@darlean/timers-suite

Version:

Timers Suite that provides persistent timer functionality

31 lines (30 loc) 1.19 kB
import { IActivatable, IDeactivatable, IPortal, ITablePersistence, ITimerCancelOptions, ITimerOptions, ITimersService, ITimerTrigger, IVolatileTimer } from '@darlean/base'; import { ITime } from '@darlean/utils'; export declare const TIMER_MOMENT_INDEX = "by-moment"; export interface ITimerState { id: string; nextMoment: number; remainingTriggers: ITimerTrigger[]; remainingRepeatCount: number; callbackActorType: string; callbackActorId: string[]; callbackActionName: string; callbackActionArgs?: unknown[]; } export declare class TimerActor implements IActivatable, IDeactivatable, ITimersService { private persistence; private time; private timer; private timerHandle?; private nextTime?; private portal; constructor(persistence: ITablePersistence<ITimerState>, time: ITime, timer: IVolatileTimer, portal: IPortal); activate(): Promise<void>; deactivate(): Promise<void>; schedule(options: ITimerOptions): Promise<void>; cancel(options: ITimerCancelOptions): Promise<void>; touch(): Promise<void>; step(): Promise<void>; private trigger; private updateNextMoment; }