import { type AtomConfig, type AtomType } from "./atom"; type TimingFunction = any>(fn: T, delay: number) => T & { cancel: () => void; flush?: () => void; }; /** * Internal factory used by `debouncedAtom` and `throttledAtom` to create a * timing-controlled reactive atom. * * **When `initialAtomOrState` is a plain value:** * A new atom is created with that value. Its `set` and `update` methods are * replaced with timing-wrapped versions so every write is gated by `timingFn`. * * **When `initialAtomOrState` is already an atom (source atom):** * A new atom is created that mirrors the source atom's current value. The new * atom's `set` and `update` are timing-wrapped, and a subscription to the * source atom is established so the derived atom stays in sync whenever the * source changes. * * In both cases, `registerCleanup` is called on the new atom so any pending * timer is cancelled automatically when the atom is disposed. * * @param initialAtomOrState - Either a plain initial value or a source `AtomType` to mirror. * @param delay - The timing window in milliseconds passed to `timingFn`. * @param timingFn - A timing higher-order function (`debounce` or `throttle`) that * wraps a function and returns it decorated with a `.cancel()` method. * @param config - Optional atom configuration forwarded to the underlying `atom()` call. * @returns A new `AtomType` whose writes are gated by `timingFn`. * * @example * // Plain value — writes are debounced/throttled directly: * const a = createTimedAtom("", 300, debounce); * a.set("hello"); // fires after 300 ms of inactivity * * @example * // Source atom — the new atom mirrors the source with timing applied: * const source = atom(0); * const timed = createTimedAtom(source, 100, throttle); * source.set(42); // timed will reflect 42, but at most once per 100 ms */ export declare const createTimedAtom: (initialAtomOrState: T | AtomType, delay: number, timingFn: TimingFunction, config?: AtomConfig) => AtomType; export {}; //# sourceMappingURL=createTimedAtom.d.ts.map