r3bl-ts-utils
Version:
The `r3bl-ts-utils` package is a set of useful TypeScript functions and classes that can be used in Node.js and browser environments. They are inspired by Kotlin stdlib, and Rust to write code as expressions rather than statements, colorized text, powerfu
37 lines (36 loc) • 1.24 kB
TypeScript
import { Optional } from "../lang-utils/core";
import { Option } from "../lang-utils/rust-lang-utils";
import { Counter } from "./counter";
export interface State {
runtimeStatus: LifecycleStage;
startTime: number;
stopTime: number;
}
export declare type TimerTickFn = (timer: Timer) => void;
declare type LifecycleStage = "created_not_started" | "running" | "stopped";
export interface Timer {
readonly name: string;
readonly delayMs: number;
readonly durationMs: number;
readonly isStopped: boolean;
readonly isRunning: boolean;
readonly isCreatedAndNotStarted: boolean;
readonly state: State;
counter?: Counter;
getOnStopFn: () => Option<TimerTickFn>;
setOnStopFn: (fn: Optional<TimerTickFn>) => void;
getOnStartFn: () => Option<TimerTickFn>;
setOnStartFn: (fn: Optional<TimerTickFn>) => void;
getOnTickFn: () => Option<TimerTickFn>;
setOnTickFn: (fn: Optional<TimerTickFn>) => void;
startTicking: () => this;
stopTicking: () => this;
toString: () => string;
}
export declare const TimerErrors: {
CantStart_AlreadyRunning: Error;
CantStop_NotStarted: Error;
CantStart_AlreadyStopped: Error;
CantStop_AlreadyStopped: Error;
};
export {};