import type { Producer } from "./Producer.ts"; /** * Tracks one reactive computation together with the producers it read during its last execution. */ export declare class Computation { #private; /** * Creates a computation with a callback that propagates invalidation. * * @param onInvalidate - Called once when the computation changes from clean to dirty. */ constructor(onInvalidate: () => void); /** * Registers a producer on the currently active computation, if there is one. * * @param producer - The producer to track on the active computation. */ static track(producer: Producer): void; /** * Runs a function without collecting dependencies on the currently active computation. * * @param func - The function to run without dependency tracking. * @returns The value returned by {@link func}. */ static untrack(func: () => T): T; /** * Marks this computation as dirty and notifies its owner once. */ invalidate(): void; /** * Returns whether the computation currently needs to rerun. * * Dirty computations with no previous dependencies need an initial run. Otherwise all tracked producers are refreshed first and * their versions are compared against the last run. * * @returns True when the computation should execute again. */ shouldRun(): boolean; /** * Runs the computation, rebuilding its dependency set from the producers read during this execution. * * @param func - The computation body to execute. * @returns The value returned by {@link func}. */ run(func: () => T): T; /** * Disposes this computation and unsubscribes it from all currently tracked producers. */ dispose(): void; }