import type { SetterReturnType } from "./subscription"; /** * Wraps a function in a reactive setter that, when called: * 1. Invokes the underlying function `fn` with any forwarded arguments. * 2. Notifies all subscribers (scheduled via `effectScheduler`). * 3. Schedules the host component for re-render (via `globalScheduler`). * * **Allowed call sites** — must be called in one of: * - A component outer function * - A `scope` class body (as a class property) * - `useState` * - A `view` component's outer function * * Cannot be created inside a template function (restricted context guard) or * inside a `setup()` method. * * @param fn - The function to wrap. Its signature is preserved when the setter * is invoked. * @param doSafetyCheck - When `true` (default), enforces the call-site guard * and the `setup()` restriction. Pass `false` only in advanced / internal * scenarios where the guard is intentionally bypassed. * @returns A callable `SetterReturnType` that forwards calls to `fn` and * exposes the following extra members: * - `__subscribe(fn)` — registers a zero-argument callback that fires * (via `effectScheduler`) every time the setter is called; returns an * unsubscribe function. * - `__version__` — read-only numeric version counter (currently always `0`; * reserved for future change-detection use). * - `__isSetter___` — `true`; type/identity discriminator. * - `set(newFn)` — swaps the underlying function without replacing the * setter reference; useful for hot-reloading or derived setters. * * @example * ```ts * // Inside a component outer function or scope class: * const count = atom(0); * const incr = setter(() => count.set(count() + 1)); * * incr(); // calls fn, notifies subscribers, schedules re-render * incr.__subscribe(() => console.log("incr called")); // fires on every call * incr.__isSetter___; // true * incr.set(() => count.set(count() + 10)); // swap underlying fn * * // $ and _ are identical aliases: * const decr = $(() => count.set(count() - 1)); * const reset = _(() => count.set(0)); * ``` */ export declare const setter: any>(fn: T, doSafetyCheck?: boolean) => SetterReturnType; export declare const $: any>(fn: T, doSafetyCheck?: boolean) => SetterReturnType; export declare const _: any>(fn: T, doSafetyCheck?: boolean) => SetterReturnType; //# sourceMappingURL=setter.d.ts.map