import { type PrimitiveProjection } from '@dxos/util'; export type CleanupFn = () => void; /** * Combine multiple cleanup functions into a single cleanup function. * Can be used in effect hooks in conjunction with `addEventListener`. */ export declare const combine: (...cleanupFns: (boolean | undefined | CleanupFn | CleanupFn[])[]) => CleanupFn; export declare const timeout: (cb: Function, ms?: number) => CleanupFn; export declare const interval: (cb: Function, ms: number) => CleanupFn; type EventMap = T extends Window ? WindowEventMap : T extends Document ? DocumentEventMap : T extends HTMLElement ? HTMLElementEventMap : Record; /** * Add the event listener and return a cleanup function. * Can be used in effect hooks in conjunction with `combine`. */ export declare const addEventListener: >(target: T, type: K, listener: (this: T, ev: EventMap[K]) => any, options?: boolean | AddEventListenerOptions) => CleanupFn; export declare class SubscriptionList { private readonly _cleanups; add(...cb: CleanupFn[]): this; clear(): void; } export declare class SubscriptionSet { private readonly _cleanupMap; constructor(keyProjection: PrimitiveProjection); set(key: T, cb: CleanupFn): this; clear(): void; } export {}; //# sourceMappingURL=cleanup.d.ts.map