/** * Callback function type for ref update notifications. * * @typeParam T - The value type of the ref */ export type RefUpdateCallback = (oldValue: T, newValue: T) => void; /** * A mutable reference wrapper that supports value updates and change notifications. * Can hold a direct value or reference another Ref, forming reference chains. * * @typeParam T - The value type being referenced * * @example * ```typescript * const ref = new Ref(42) * ref.onUpdate((old, newVal) => console.log(`Changed from ${old} to ${newVal}`)) * ref.update(100) // Logs: Changed from 42 to 100 * ``` */ export declare class Ref { /** The current value or a reference to another Ref */ value: T | Ref; /** Registered callbacks for update notifications */ callbacks: Array>; modified: boolean; protected immutable: boolean; /** * Creates a new Ref with an initial value. * * @param value - The initial value or another Ref to chain * @throws Error if attempting to create a self-referencing Ref */ constructor(value: T | Ref); isModified(): boolean; setModified(modified?: boolean): void; setImmutable(immutable?: boolean): void; isImmutable(): boolean; /** * Updates the reference to a new value or another Ref. * Notifies all registered callbacks of the change. * * @param newValue - The new value or Ref to point to */ update(newValue: T | Ref): void; /** * Resolves the reference chain to get the final value. * * @returns The resolved value of type T */ resolve(): T; /** * Compares this Ref's resolved value with another value or Ref. * * @param other - The value or Ref to compare against * @returns True if the resolved values are equal */ equals(other?: Ref | T): boolean; /** * Registers a callback to be notified when the value changes. * * @param callback - The function to call on value updates */ onUpdate(callback: RefUpdateCallback): void; /** Creates a new Ref with the same resolved value. */ clone(): Ref; }