import { ReadonlyStore, Unsubscribe } from './store.js'; export declare const effectRuntime: { /** * The effect that is currently being "instantiated". * The instantiation of an effect corresponds to its first run. */ instantiatingEffect: Effect | undefined; /** * The number of effect ever register during the process runtime. This number is * used as an auto-increment ID. */ effectCount: number; /** * Counter that is used to check if we can run effects triggered by a store * changing immediately or whether we should enqueue them to run them after * all stores have been updated. */ isBatching: number; /** Map */ pendingEffectBatch: Map void>; /** Map */ effectById: Map; /** Counter of the number of reactive roots. */ reactiveRootCount: number; /** Map */ rootByEffectId: Map; /** Map */ rootUnsubscribes: Map; }; type Effect = { id: number; effectFn: () => void | (() => void); cleanupFn?: () => void; dependencies: number[]; }; /** * Error thrown if one or more cleanup functions registered by the effects inside a reactive * root raised an exception. */ export declare class ReactiveRootDisposeError extends Error { errors: unknown[]; constructor(errors: unknown[]); } /** * Error thrown if one or more effects that were queued during a batchEffects call * raised an exception. */ export declare class BatchingEffectError extends Error { errors: unknown[]; constructor(errors: unknown[]); } /** * Error thrown if makeEffect is called inside an effect. */ export declare class NestedEffectError extends Error { constructor(); } /** * A reactive root provides a scope for all the effect it contains. * This scope can then be destroyed (and all the effect cleaned up) by calling * the dispose method. */ export type ReactiveRoot = { /** * Create an effect. * * NOTE: makeEffect calls cannot be nested. * * @param fn A function that watches one or more stores and reacts to their changes. The function can optionally return * a cleanup procedure that will run before the next effect takes place. */ makeEffect(fn: () => void | (() => void)): void; /** * Call all the cleanup functions registered by all the effects in this reactive root. */ dispose(): void; }; /** * Create a {@link ReactiveRoot}, providing a makeEffect and a dispose function. */ export declare function makeReactiveRoot(): ReactiveRoot; /** * Run the passed function, enqueueing and deduplicating the effects it may trigger, in order to * run them just at the end to avoid "glitches". * * NOTE: batchEffects can be nested, all updates will automatically be accumulated in the outmost "batch" before * the effects are executed. * * @param action A function that directly or indirectly updates one or more stores. */ export declare function batchEffects(action: () => void): void; /** * Get the content of a store and register a subscription for the wrapping effect (if any). * * NOTE: __for internal use only__ * @param store$ a partial store containing just the `subscriber` and `content` method. */ export declare function radioActiveContent(storeId: number, store$: Pick, 'subscribe' | 'content'>): T; export {};