import type { Subscriber, Unsubscriber } from './types.js'; type StartStopNotifier = (set: Subscriber, update: (fn: Updater) => void) => Unsubscriber | void; export type Updater = (value: T) => T; export type { Subscriber, Unsubscriber }; export interface ReadonlyStore { /** * Return the current value. */ readonly state: T; /** * Subscribe to changes with a callback. Returns an unsubscribe function. * Pass `false` as the second argument to skip the immediate initial call. */ subscribe(callback: Subscriber, noInit?: false): Unsubscriber; } export interface Store extends ReadonlyStore { /** * Get or set the current value. */ state: T; } /** * Clear the global reactive store context. Useful for testing to ensure a clean state between tests. */ export declare function clearAllContext(): void; export declare class ReadonlyStoreClass { #private; constructor(initialValue?: T, start?: StartStopNotifier); get state(): T; protected set state(value: T); /** * Subscribe to changes with a callback. Returns an unsubscribe function. * Pass `false` as the second argument to skip the immediate initial call. */ subscribe: (callback: Subscriber, noInit?: false) => Unsubscriber; } export declare class StoreClass extends ReadonlyStoreClass { get state(): T; set state(value: T); } /** * Creates a `ReadonlyStore` that allows reading by subscription. */ export declare function readonly(initialValue?: T, start?: StartStopNotifier): ReadonlyStore; /** * Create a `Store` that allows both updating and reading by subscription. */ export declare function store(value: T, start?: StartStopNotifier): Store; /** * Watch stores and computed values by running a function whenever any stores accessed within it change. */ export declare function watch(fn: (priorReturn: T) => T): Unsubscriber; /** * Create a `ReadonlyStore` that computes its value from other stores and updates when those stores change. */ export declare function computed(fn: (priorValue: T) => T, value?: T): ReadonlyStore; /** * Allows setting multiple stores at once and only notifying subscribers once after the batch function is run. */ export declare function batch(fn: () => void): void; /** * Provides a promise that resolves when the store is no longer `null` or `undefined`. */ export declare function whenReady(store: ReadonlyStore): Promise; /** * Provides a promise that resolves when the store's value meets the provided condition. */ export declare function whenMatches(store: ReadonlyStore, matches: (value: T) => boolean): Promise; /** * Provides a promise that resolves after the store changes and returns the new value. */ export declare function afterChange(store: ReadonlyStore): Promise;