/** * Global state and batching for the reactive system. */ import type { Computed } from "./computed.js"; /** Callback function for subscribers */ export type Subscriber = () => void; /** * Minimal interface for dependency tracking sources. * Implemented by Signal, Computed, and selector slots. */ export interface TrackableSource { targets: Computed[]; deleteTarget(target: Computed): void; } /** The currently executing computed (for dependency tracking) */ export declare let context: Computed | null; /** Set the current execution context */ export declare function setContext(c: Computed | null): void; /** * Batch multiple signal updates into a single notification pass. * Subscribers are only notified after the batch function completes. */ export declare function batch(fn: () => T): T; /** Check if currently batching */ export declare function isBatching(): boolean; /** Add a subscriber to the batch queue */ export declare function enqueueBatchOne(sub: Subscriber): void; /** Add multiple subscribers to the batch queue */ export declare function enqueueBatchAll(subs: Subscriber[]): void; /** Scope disposal: collect all disposers in a scope */ export declare let disposalStack: Array void>> | null; /** * Create a disposal scope that collects all subscriptions and computeds created within. * Returns the result of the function and a dispose function that cleans up all resources. * * @example * ```ts * const [result, dispose] = scope(() => { * const count = signal(0); * const doubled = computed(() => count.value * 2); * effect(() => console.log(doubled.value)); * return { count, doubled }; * }); * * // Later: clean up all subscriptions and computeds * dispose(); * ``` */ export declare function scope(fn: () => T): [result: T, dispose: () => void]; /** * Register a disposer in the current scope (if any). * This is called internally by computed/effect when they create cleanup functions. */ export declare function registerDisposer(dispose: () => void): void; /** * Hook for tracking signal/computed accesses. * Set by async.ts when track() is active to capture dependencies. * Using an object wrapper so async.ts can mutate the current value. */ export declare const onTrack: { current: ((source: TrackableSource) => void) | null; }; //# sourceMappingURL=context.d.ts.map