Home / Class/ value Class — svelte Architecture

value Class — svelte Architecture

Architecture documentation for the value class in index.d.ts from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  d3fb0283_3deb_24b7_677b_9d1973529edb["value"]
  6bd9d090_a582_e05c_669e_d53d4e7245f2["index.d.ts"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|defined in| 6bd9d090_a582_e05c_669e_d53d4e7245f2
  1b47a977_16c0_6359_434e_be5132b2a989["subscribe()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| 1b47a977_16c0_6359_434e_be5132b2a989
  724f30f7_fbf1_68d3_702c_fe3c98bc019f["set()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| 724f30f7_fbf1_68d3_702c_fe3c98bc019f
  fa6e34cc_9b3f_c7b3_8288_97acf4d319a8["update()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| fa6e34cc_9b3f_c7b3_8288_97acf4d319a8
  2fe1ea4e_abaa_dfd9_f050_e2de7f21cbc7["toStore()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| 2fe1ea4e_abaa_dfd9_f050_e2de7f21cbc7
  97aa2acc_14c1_94c2_5149_c16b1b457218["fromStore()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| 97aa2acc_14c1_94c2_5149_c16b1b457218
  c17312cf_02c8_43f0_a886_ed15c732d1a7["readable()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| c17312cf_02c8_43f0_a886_ed15c732d1a7
  34b4786c_99f8_eba9_d919_202af3270d8f["writable()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| 34b4786c_99f8_eba9_d919_202af3270d8f
  204cf825_db86_d049_7c3c_ec3a3e4d3bb7["derived()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| 204cf825_db86_d049_7c3c_ec3a3e4d3bb7
  eae27bda_77c5_58b0_6729_529be89b03c2["readonly()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| eae27bda_77c5_58b0_6729_529be89b03c2
  8a0fc1c2_5ab5_03f0_8ce3_eff6c5ed3a6a["get()"]
  d3fb0283_3deb_24b7_677b_9d1973529edb -->|method| 8a0fc1c2_5ab5_03f0_8ce3_eff6c5ed3a6a

Relationship Graph

Source Code

packages/svelte/types/index.d.ts lines 2596–2698

declare module 'svelte/store' {
	/** Callback to inform of a value updates. */
	export type Subscriber<T> = (value: T) => void;

	/** Unsubscribes from value updates. */
	export type Unsubscriber = () => void;

	/** Callback to update a value. */
	export type Updater<T> = (value: T) => T;

	/**
	 * Start and stop notification callbacks.
	 * This function is called when the first subscriber subscribes.
	 *
	 * @param set Function that sets the value of the store.
	 * @param update Function that sets the value of the store after passing the current value to the update function.
	 * @returns Optionally, a cleanup function that is called when the last remaining
	 * subscriber unsubscribes.
	 */
	export type StartStopNotifier<T> = (
		set: (value: T) => void,
		update: (fn: Updater<T>) => void
	) => void | (() => void);

	/** Readable interface for subscribing. */
	export interface Readable<T> {
		/**
		 * Subscribe on value changes.
		 * @param run subscription callback
		 * @param invalidate cleanup callback
		 */
		subscribe(this: void, run: Subscriber<T>, invalidate?: () => void): Unsubscriber;
	}

	/** Writable interface for both updating and subscribing. */
	export interface Writable<T> extends Readable<T> {
		/**
		 * Set value and inform subscribers.
		 * @param value to set
		 */
		set(this: void, value: T): void;

		/**
		 * Update value using callback and inform subscribers.
		 * @param updater callback
		 */
		update(this: void, updater: Updater<T>): void;
	}
	export function toStore<V>(get: () => V, set: (v: V) => void): Writable<V>;

	export function toStore<V>(get: () => V): Readable<V>;

	export function fromStore<V>(store: Writable<V>): {
		current: V;
	};

	export function fromStore<V>(store: Readable<V>): {
		readonly current: V;
	};
	/**
	 * Creates a `Readable` store that allows reading by subscription.
	 *
	 * @param value initial value
	 * */
	export function readable<T>(value?: T | undefined, start?: StartStopNotifier<T> | undefined): Readable<T>;
	/**
	 * Create a `Writable` store that allows both updating and reading by subscription.
	 *
	 * @param value initial value
	 * */
	export function writable<T>(value?: T | undefined, start?: StartStopNotifier<T> | undefined): Writable<T>;
	/**
	 * Derived value store by synchronizing one or more readable stores and
	 * applying an aggregation function over its input values.
	 *
	 * */
	export function derived<S extends Stores, T>(stores: S, fn: (values: StoresValues<S>, set: (value: T) => void, update: (fn: Updater<T>) => void) => Unsubscriber | void, initial_value?: T | undefined): Readable<T>;
	/**
	 * Derived value store by synchronizing one or more readable stores and
	 * applying an aggregation function over its input values.
	 *

Frequently Asked Questions

What is the value class?
value is a class in the svelte codebase, defined in packages/svelte/types/index.d.ts.
Where is value defined?
value is defined in packages/svelte/types/index.d.ts at line 2596.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free