/** * Computed - A derived reactive value. */ import { type Subscriber, type TrackableSource } from "./context.js"; /** * A derived reactive value. Automatically tracks dependencies and * recomputes when any dependency changes. * * Uses Object.is() for equality checks to correctly handle NaN values. */ export declare class Computed { #private; constructor(fn: () => T); get value(): T; subscribe(fn: Subscriber): () => void; dispose(): void; /** * Check if the computed's value equals the given value. * Enables O(1) selection updates - only the old and new matching values * trigger recomputes, not all dependents. * * @example * ```ts * const selected = computed(() => items.find(i => i.active)?.id ?? null); * * // In each row - only 2 rows recompute when selection changes * html` selected.is(row.id) ? 'danger' : ''}>...` * ``` */ is(value: T): boolean; /** * Called by sources when accessed during recompute. * @internal */ trackSource(source: TrackableSource): void; /** * Mark this computed and all its dependents as dirty. * Uses a two-phase approach to avoid cascading issues: * 1. Mark all dependents as dirty (no subscriber calls) * 2. Notify subscribers after all dirty flags are set * @internal */ markDirty(): void; /** @internal */ get targets(): Computed[]; /** @internal */ deleteTarget(target: Computed): void; } /** Create a new computed from the given function. */ export declare const computed: (fn: () => T) => Computed; //# sourceMappingURL=computed.d.ts.map