```js // @noErrors import { derived, fromStore, get, readable, readonly, toStore, writable } from 'svelte/store'; ``` ## derived Derived value store by synchronizing one or more readable stores and applying an aggregation function over its input values. ```dts function derived( stores: S, fn: ( values: StoresValues, set: (value: T) => void, update: (fn: Updater) => void ) => Unsubscriber | void, initial_value?: T | undefined ): Readable; ``` ```dts function derived( stores: S, fn: (values: StoresValues) => T, initial_value?: T | undefined ): Readable; ``` ## fromStore ```dts function fromStore(store: Writable): { current: V; }; ``` ```dts function fromStore(store: Readable): { readonly current: V; }; ``` ## get Get the current value from a store by subscribing and immediately unsubscribing. ```dts function get(store: Readable): T; ``` ## readable Creates a `Readable` store that allows reading by subscription. ```dts function readable( value?: T | undefined, start?: StartStopNotifier | undefined ): Readable; ``` ## readonly Takes a store and returns a new one derived from the old one that is readable. ```dts function readonly(store: Readable): Readable; ``` ## toStore ```dts function toStore( get: () => V, set: (v: V) => void ): Writable; ``` ```dts function toStore(get: () => V): Readable; ``` ## writable Create a `Writable` store that allows both updating and reading by subscription. ```dts function writable( value?: T | undefined, start?: StartStopNotifier | undefined ): Writable; ``` ## Readable Readable interface for subscribing. ```dts interface Readable {/*…*/} ``` ```dts subscribe(this: void, run: Subscriber, invalidate?: () => void): Unsubscriber; ``` * `run` subscription callback * `invalidate` cleanup callback Subscribe on value changes. ## StartStopNotifier Start and stop notification callbacks. This function is called when the first subscriber subscribes. ```dts type StartStopNotifier = ( set: (value: T) => void, update: (fn: Updater) => void ) => void | (() => void); ``` ## Subscriber Callback to inform of a value updates. ```dts type Subscriber = (value: T) => void; ``` ## Unsubscriber Unsubscribes from value updates. ```dts type Unsubscriber = () => void; ``` ## Updater Callback to update a value. ```dts type Updater = (value: T) => T; ``` ## Writable Writable interface for both updating and subscribing. ```dts interface Writable extends Readable {/*…*/} ``` ```dts set(this: void, value: T): void; ``` * `value` to set Set value and inform subscribers. ```dts update(this: void, updater: Updater): void; ``` * `updater` callback Update value using callback and inform subscribers.