UNPKG

resig.js

Version:

Universal reactive signal library with complete platform features: signals, animations, CRDTs, scheduling, DOM integration. Works identically across React, SolidJS, Svelte, Vue, and Qwik.

51 lines (50 loc) 1.78 kB
/** * Scheduler - Stream coalgebra for managing async operations and animations * Following coalgebraic principles for time-evolving systems */ import { Signal } from '../core/signal'; export declare enum Priority { IMMEDIATE = 0, HIGH = 1, NORMAL = 2, LOW = 3, IDLE = 4 } export interface Task { readonly id: string; readonly priority: Priority; readonly execute: () => void | Promise<void>; readonly cancel?: () => void; readonly delay?: number; readonly repeat?: boolean | number; } export interface SchedulerState { readonly running: boolean; readonly taskCount: number; readonly completedTasks: number; readonly failedTasks: number; } export interface Scheduler { readonly state: Signal<SchedulerState>; readonly schedule: (task: Task) => string; readonly cancel: (taskId: string) => boolean; readonly start: () => void; readonly stop: () => void; readonly clear: () => void; } export declare const scheduler: () => Scheduler; export declare const getGlobalScheduler: () => Scheduler; export declare const schedule: (task: Omit<Task, 'id'> & { id?: string; }) => string; export declare const cancel: (taskId: string) => boolean; export declare const delay: (ms: number) => Promise<void>; export declare const nextFrame: () => Promise<void>; export declare const idle: (callback: () => void) => string; export declare const animate: (duration: number, callback: (progress: number) => void, easing?: (t: number) => number) => string; export declare const debounce: <T extends (...args: any[]) => void>(fn: T, delay: number) => T & { cancel: () => void; }; export declare const throttle: <T extends (...args: any[]) => void>(fn: T, delay: number) => T & { cancel: () => void; };