import { Effect, type Scope } from "effect"; /** * A trailing-edge debouncer over a plain callback. Every `trigger` restarts the * wait; the callback runs once the last trigger has been quiet for the * configured window. */ export interface Debounced { /** Restarts the wait. A no-op after `cancel`. */ readonly trigger: Effect.Effect; /** * `trigger` for synchronous callers such as an `fs.watch` listener. Runs in a * fiber owned by the debouncer's scope; nothing is returned to await. */ triggerUnsafe(): void; /** * Drops the pending callback and disposes the debouncer: later triggers do * nothing. Idempotent. */ readonly cancel: Effect.Effect; /** `cancel` for synchronous callers. */ cancelUnsafe(): void; } /** * Creates a trailing-edge debouncer that calls `onChange` once `ms` * milliseconds have passed without a trigger. Bursty sources (an editor save * storm seen through `fs.watch`, a `git fetch` writing many refs) collapse into * one call. * * The pending callback lives in a fiber forked into the calling scope, so * closing that scope drops it; the scope's finalizer also cancels the * debouncer. Sleeping uses the Effect `Clock`, so `TestClock` drives it in * tests. */ export declare const makeDebounced: (onChange: () => void, ms: number) => Effect.Effect;