import { Effect, Signal } from './types.js'; /** * Run multiple signal writes as a single atomic update. * All effects and renders triggered inside fn() are deferred until the batch * completes, so each subscriber fires at most once. * * @example * batch(() => { * setPrice(newPrice); // ← would each trigger a render separately * setVolume(newVolume); // ← now both are coalesced into one render * }); */ export declare function batch(fn: () => void): void; export declare function setCurrentObserver(observer: Effect | null): void; export declare function getCurrentObserver(): Effect | null; export interface SignalOptions { /** * Custom equality function. If it returns true the setter is a no-op and * no subscribers are notified. * Pass `false` to disable equality checks entirely (always notify). * * @default Object.is * @example * // Deep-equal arrays — only re-render when contents actually change * const [items, setItems] = signal([], { equals: (a, b) => JSON.stringify(a) === JSON.stringify(b) }); * * // Always notify (useful for objects mutated in place) * const [state, setState] = signal(obj, { equals: false }); */ equals?: ((a: T, b: T) => boolean) | false; } /** * Fine-grained signal. Calling getter() inside a tracking context * auto-subscribes the observer to this signal. * * @example * const [count, setCount] = signal(0); * setCount(1); // set directly * setCount(n => n + 1); // updater function * console.log(count()); // 2 */ export declare function signal(initialValue: T, options?: SignalOptions): Signal; /** * Derived signal. Lazily re-computes when any tracked dependency changes. * Reading computed() inside a tracking context also subscribes the observer * to this computed's upstream dependencies. * * @example * const [first, setFirst] = signal('Ada'); * const [last, setLast] = signal('Lovelace'); * const full = computed(() => `${first()} ${last()}`); * console.log(full()); // 'Ada Lovelace' * setFirst('Grace'); * console.log(full()); // 'Grace Lovelace' */ export declare function computed(fn: () => T): () => T;