import { get_store_value } from 'svelte/internal'; /** Callback to inform of a value updates. */ declare type Subscriber = (value: T) => void; /** Unsubscribes from value updates. */ declare type Unsubscriber = () => void; /** Callback to update a value. */ declare type Updater = (value: T) => T; /** Cleanup logic callback. */ declare type Invalidator = (value?: T) => void; /** Start and stop notification callbacks. */ declare type StartStopNotifier = (set: Subscriber) => Unsubscriber | void; /** Readable interface for subscribing. */ export interface Readable { /** * Subscribe on value changes. * @param run subscription callback * @param invalidate cleanup callback */ subscribe(run: Subscriber, invalidate?: Invalidator): Unsubscriber; } /** Writable interface for both updating and subscribing. */ export interface Writable extends Readable { /** * Set value and inform subscribers. * @param value to set */ set(value: T): void; /** * Update value using callback and inform subscribers. * @param updater callback */ update(updater: Updater): void; } /** * Creates a `Readable` store that allows reading by subscription. * @param value initial value * @param {StartStopNotifier}start start and stop notifications for subscriptions */ export declare function readable(value: T, start: StartStopNotifier): Readable; /** * Create a `Writable` store that allows both updating and reading by subscription. * @param {*=}value initial value * @param {StartStopNotifier=}start start and stop notifications for subscriptions */ export declare function writable(value: T, start?: StartStopNotifier): Writable; /** One or more `Readable`s. */ declare type Stores = Readable | [Readable, ...Array>]; /** One or more values from `Readable` stores. */ declare type StoresValues = T extends Readable ? U : { [K in keyof T]: T[K] extends Readable ? U : never; }; /** * Derived value store by synchronizing one or more readable stores and * applying an aggregation function over its input values. * * @param stores - input stores * @param fn - function callback that aggregates the values * @param initial_value - when used asynchronously */ export declare function derived(stores: S, fn: (values: StoresValues, set: (value: T) => void) => Unsubscriber | void, initial_value?: T): Readable; /** * Derived value store by synchronizing one or more readable stores and * applying an aggregation function over its input values. * * @param stores - input stores * @param fn - function callback that aggregates the values */ export declare function derived(stores: S, fn: (values: StoresValues) => T): Readable; /** * Get the current value from a store by subscribing and immediately unsubscribing. * @param store readable */ export { get_store_value as get };